我使用以下代码将 UIPanGuestureRecognizer 添加到整个视图中:
UIPanGestureRecognizer *pgr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
[[self view] addGestureRecognizer:pgr];
在主视图中,我有一个 UITableView,其中包含启用滑动删除功能的代码:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"RUNNING2");
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row >= _firstEditableCell && _firstEditableCell != -1)
NSLog(@"RUNNING1");
return YES;
else
return NO;
}
只有RUNNING1
打印到日志中,删除按钮不显示。我相信这是因为 UIPanGestureRecognizer,但我不确定。如果这是正确的,我应该如何解决这个问题。如果这不正确,请提供原因并修复。谢谢。