2013-07-17 4 views
1

나는 각 행에 UIImageUILongPressGestureRecognizer으로 추가 된 UITableView이 있습니다. 이제 문제가 생겼습니다. imageView를 터치하면 제스처 인식기의 코드가 수행됩니다. 그러나 손가락을 위/아래로 움직이면 표보기가 스크롤되지 않습니다.UILongPressGestureRecognizer 및 UITableview

터치가 여전히 제스처 인식기 안에 있으므로 분명합니다.

내 제스처 인식기에서 tableView를 스크롤하는 방법이 있습니까? 즉, 제스처에있을 때 인식기와 손가락이 위로 움직이면 tableView Scrolling 메서드를 호출하는 것보다?

+1

'yourLongPressGestureRecognizer.allowableMovement = 0'과이 같은 대리자 메서드를 구현해야합니다 :'- (BOOL)를 gestureRecognizer : (UIGestureRecognizer *) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer : (UIGestureRecognizer *) otherGestureRecognizer { return 예; }' – tassar

답변

1

내가 그것을 당신에게 유용 할 수있다 생각

 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
                    initWithTarget:self 
                    action:@selector(handleLongPress:)]; 
    longPress.minimumPressDuration = 1.0; 
    [cell addGestureRecognizer:longPress]; 

    - (void)handleLongPress:(UILongPressGestureRecognizer*)sender { 
     CGPoint location = [sender locationInView:yourtableviewobj]; 
     //Get the corresponding index path within the table view 
     NSIndexPath *indexPath = [self.tablechat indexPathForRowAtPoint:location]; 
     if (sender.state == UIGestureRecognizerStateEnded) { 
     } 
     else if (sender.state == UIGestureRecognizerStateBegan){ 
     } 
    } 
+0

다른 tableview - 문제를 테스트하는 데 도움이되었다 :) – jerik

관련 문제