我在视图中添加了一个 UISwipeGestureRecognizer,它根据用户滑动的方向(向左或向右)更改视图的内容。但是,如果用户在 UITableViewCell 中滑动,则触摸将被忽略,并且滑动删除功能永远不会出现。如何将此触摸传递给 UITableViewCell?
我做了什么:
[swipeLeft setCancelsTouchesInView:NO];
[swipeRight setCancelsTouchesInView:NO];
-(void)swipeLeft:(UISwipeGestureRecognizer *)gesture {
BOOL touchedInsideCell = NO;
CGPoint touchedPoint = [gesture locationInView:gesture.view];
for (PCFCustomScheduleCell *cell in self.tableView.visibleCells) {
CGRect cellFrame = cell.frame;
if (CGRectContainsPoint(cellFrame, touchedPoint)) {
touchedInsideCell = YES;
break;
}
}
if (touchedInsideCell == NO) {
if (recordOfDay < 5) {
recordOfDay++;
[self.tableView reloadData];
}
}else {
//I need to pass the touch to the UITableViewCell, as the swipe to delete feature is not working
}
}
我已经在 canEditRowAtIndexPath 方法中返回了 YES,如果我不添加这些手势识别器,它就会起作用。我错过了什么?
谢谢!