Ios UISwipeGestureRecognitor on view-如果触摸在UITableViewCell内,如何将其传递到该单元格?
我在视图中添加了一个UISweepGestureRecognitor,它根据用户的滑动方向(向左或向右)更改视图的内容。但是,如果用户在UITableViewCell中刷卡,触摸将被忽略,并且“刷卡删除”功能将永远不会显示。如何将此触摸传递到UITableViewCell 我所做的:Ios UISwipeGestureRecognitor on view-如果触摸在UITableViewCell内,如何将其传递到该单元格?,ios,objective-c,cocoa-touch,uitableview,uigesturerecognizer,Ios,Objective C,Cocoa Touch,Uitableview,Uigesturerecognizer,我在视图中添加了一个UISweepGestureRecognitor,它根据用户的滑动方向(向左或向右)更改视图的内容。但是,如果用户在UITableViewCell中刷卡,触摸将被忽略,并且“刷卡删除”功能将永远不会显示。如何将此触摸传递到UITableViewCell 我所做的: [swipeLeft setCancelsTouchesInView:NO]; [swipeRight setCancelsTouchesInView:NO]; -(void)swipeLeft
[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
}
}
[swipeLeft setCancelsTouchesInView:否];
[swipeRight设置取消触摸视图:否];
-(无效)swipeLeft:(UISweepGestureRecognitor*)手势{
BOOL-touchedInsideCell=否;
CGPoint touchedPoint=[手势位置视图:手势.视图];
用于(self.tableView.VisibleCell中的PCFCustomScheduleCell*单元格){
CGRect cellFrame=cell.frame;
if(CGRectContainsPoint(单元格框、接触点)){
touchedInsideCell=是;
打破
}
}
if(touchedInsideCell==否){
如果(记录日期<5){
recordOfDay++;
[self.tableView重载数据];
}
}否则{
//我需要将触摸传递到UITableViewCell,因为滑动删除功能不起作用
}
}
我已经在canEditRowAtIndexPath方法中返回了YES,如果我不添加这些手势识别器,它就会工作。我错过了什么
谢谢 让您的班级成为手势识别器的代表,然后您可以决定手势是否应处理任何传入的触摸。您是手势识别器的代表,并决定它是否应处理触摸?谢谢,我不知道为什么我没有想到这一点。如果你把这个贴在下面,我可以把你的答案标记为被接受的答案。