0

私のUITableViewCellには、セル内の画像をスワイプするためのUISwipeGestureRecognizerがありました。たとえば、GestureRecognizerはメソッドを呼び出し、イメージを増分して行をリロードします。タッチされた行を定義し、それをメソッドに渡す方法は?UITableViewCell内のUIGestureRecognizer

+0

いくつかのコードを含めることはできますか?あなたがスワイプを扱う方法は素晴らしいでしょう。 – jrturton

答えて

1

タッチ座標からスワイプセルを定義できることがわかりました。

if (recognizer.state == UISwipeGestureRecognizerStateEnded) { 
    CGPoint gestureLocation = [recognizer locationInView:self.tableView]; 
    NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:gestureLocation]; 
//found IndexPath for swiped cell. Now we can do anything what we need. 
//In my case it's cell reloading with new image in UIImageView. 
NSArray *rowsToReload = [[NSArray alloc] initWithObjects:swipedIndexPath, nil]; 
[self.tableView reloadRowsAtIndexPaths:rowsToReload withRowAnimation:UITableViewRowAnimationNone]; 
+0

ifステートメントには閉じ括弧がありません。 –

0

おそらく、セルの選択を無効にする必要があります。通常はセルの再読み込みがトリガーされます。

関連する問題