为什么 touchesBegan 方法代码会在我的 UITableView 中触发?
背景:我在 UINavigationController 中有一个 UITableView。在 UITableView 中,我有基于子类 UITableViewCell 的自定义单元格。我目前在我的 UITableView 中没有 selectRowAtIndexPath 方法。
可以很好地掩盖答案的某些方面包括:
为什么它显然不起作用
就让它工作而言,如何确保正确的触摸(单击)检测不会阻止其他场景的工作,例如:选择表格行,上下滚动表格视图内容等。
模拟器是否应该能够拾取触摸等,或者这里是否存在您需要物理设备的情况
代码:
@interface AppointmentListController : UITableViewController <UIActionSheetDelegate>
.
.
.
@implementation AppointmentListController
.
.
.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
timeStampStart = event.timestamp;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSTimeInterval timeStampEnd = event.timestamp;
NSTimeInterval touchDuration = timeStampEnd - timeStampStart;
if(touchDuration > 0.2)
[super touchesEnded:touches withEvent:event];
else
DLog(@" - TOUCH EVENT OCCURS");
[super touchesEnded:touches withEvent:event];
}