TableView editingStyleForRowAtIndexPath:没有用UIPanGestureRecognizer调用?
问题描述:
我正在使用显示用户列表的UITableView。我已经实现委托方法:TableView editingStyleForRowAtIndexPath:没有用UIPanGestureRecognizer调用?
- (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];
}
}
}
答
试试这个方法
在.m文件只实现无需调用
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:gestureRecognizer.view];
return fabs(velocity.x) > fabs(velocity.y);
}
UITapGestureRecognizer *自来水= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard :)]; \t tap.cancelsTouchesInView = NO; [self.view addGestureRecognizer:tap]; – OMGHaveFun