2011-03-25 21 views
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]; 
    } 

回答

0

想把了这是一个可能的答案,答案是没有相对笔直的路,实现什么我已经要求这个了。这是一种在UITableView页面中检测轻拍或双击的方法,该页面已经在拾取行触摸并向上/向下滚动等。

尚未验证是否是这种情况,但是如果他们认为这是真的,人们可以对这个答案进行投票。

相关问题