テーブルビューがあり、セクション A で行をスワイプしてからセクション B で行を選択すると、セクション A でスワイプした行を選択したと見なされます。検証するブレークポイントを配置しましたが、それがそのセルであると考えられ、セクション B の行を選択したときにそれが呼び出されることを 100% 確信しています。
スワイプとは、セルの一部に指を置き、それをドラッグして (左右は関係ありません)、離すことを意味します。これはタップではないため、didSelectRowAtIndexPath を呼び出しません。
例:
indexpath をスワイプ A.1 indexpath
をタップ B.4
OS 呼び出し tableView:didSelectRowAtIndexPath: A.1
私は何か間違ったことをしていますか?何が問題になる可能性がありますか?
特定のセルでのタッチを処理する完全なコード:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
RDLogString(@"(%p) Received touches began", self);
moveCount = 0;
UITouch * touch = [touches anyObject];
touchBegin = [touch locationInView: nil];
[[self nextResponder] touchesBegan: touches withEvent: event];
}
- (void) touchesMoved: (NSSet * const)touches withEvent:(UIEvent * const)event {
RDLogString(@"(%p) Received touches moved", self);
moveCount++;
[[self nextResponder] touchesMoved: touches withEvent: event];
}
- (void) touchesEnded: (NSSet * const)touches withEvent:(UIEvent * const)event {
RDLogString(@"(%p) Received touches ended", self);
if(![self checkUserSwipedWithTouches: touches]){
[[self nextResponder] touchesEnded: touches withEvent: event];
}
}
- (BOOL) checkUserSwipedWithTouches: (NSSet * const) touches {
CGPoint touchEnd = [[touches anyObject] locationInView: nil];
NSInteger distance = touchBegin.x - touchEnd.x;
// This code shows an animation if the user swiped
if(distance > SWIPED_HORIZONTAL_THRESHOLD){
[self userSwipedRightToLeft: YES];
return YES;
} else if (distance < (-SWIPED_HORIZONTAL_THRESHOLD)) {
[self userSwipedRightToLeft: NO];
return YES;
}
return NO;
}