我正在使用显示用户列表的UITableView。我已经实现了委托方法:
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
通过在单元格上向左滑动来删除用户记录,它工作正常,但现在我将UIPanGestureRecognizer添加到控制器,通过在视图中右键滑动返回。现在问题是tableView委托方法没有被正确调用。因此,任何帮助/建议将不胜感激如何处理案件。谢谢
这是我的UIPanGestureRecognizer操作:
-(void)performAction:(UIPanGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateChanged){
velocity = [sender velocityInView:self.view];
NSLog(@"Velocity X: %f Y: %f",velocity.x,velocity.y);
}
else if (sender.state == UIGestureRecognizerStateEnded){
BOOL isHorizentalMotion = fabs(velocity.x) > fabs(velocity.y);
BOOL isHorizentallyLeft = velocity.x < 0 ? YES : NO;
BOOL isHorizentallyRight = velocity.x > 0 ? YES : NO;
if (isHorizentalMotion && isHorizentallyRight) {
NSLog(@"RIGHT GESTURE");
[self menuClicked:nil];
}
}
}
答案 0 :(得分:0)
尝试此方法
只需在你的.m文件中实现,无需调用
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:gestureRecognizer.view];
return fabs(velocity.x) > fabs(velocity.y);
}