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

아마도 셀 선택을 해제해야합니다. 일반적으로 셀을 다시로드하도록 트리거합니다.

관련 문제