NSIndexPath
ジェスチャレコグナイザーセレクターでの受信に問題があります。ジェスチャレコグUITableViewController:viewDidLoad
ナイザーを初期化する場合
UISwipeGestureRecognizer* rightSwipeGestureRecognizer =
[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.tableView addGestureRecognizer:rightSwipeGestureRecognizer];
行インデックスを取得しようとしているジェスチャハンドラーimで:
- (void) swipeRight: (UISwipeGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
NSInteger row = swipedIndexPath.row;
NSLog(@"Row %d", swipedIndexPath.row);
}
CGPointは正しいですが、行は常に0です。理由は何ですか?