【发布时间】:2011-03-25 21:34:27
【问题描述】:
为什么 touchesBegan 方法代码会在我的 UITableView 中触发?
背景:我在 UINavigationController 中有一个 UITableView。在 UITableView 中,我有基于子类 UITableViewCell 的自定义单元格。我目前在我的 UITableView 中没有 selectRowAtIndexPath 方法。
答案的某些方面可以很好地掩盖,包括:
为什么不明显
就让它工作而言,get one 如何确保正确的触摸(单击)检测不会阻止其他场景的工作,例如:选择表格行、向上滚动表格视图内容和下等。
模拟器是否应该能够拾取触摸等,或者这里是否存在需要物理设备的情况
代码:
@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];
}
【问题讨论】:
标签: iphone cocoa-touch ios uitableview touches