0
touchesBegan方法代码为什么会在我的UITableView中触发?为什么这touchesBegan方法代码得到我的UITableView触发器?
背景:我有一个UINavigationController内的UITableView。在UITableView中,我有基于UITableViewCell子类的自定义单元格。我目前在我的UITableView中没有selectRowAtIndexPath方法。
的答案,将是很好的遮盖掉将包括若干方面:
为什么它不会得到它的工作方面显然工作
,如何得到一个确保正确的触摸(单击)检测不会阻止其他场景工作,如:选择表格行,上下滚动tableview内容等。
模拟器应该能够拾取触摸等,或在这里,你所需要的物理设备存在的情况下
代码:
@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];
}