【问题标题】:why does this touchesBegan method code get trigger in my UITableView?为什么这个 touchesBegan 方法代码会在我的 UITableView 中触发?
【发布时间】: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


    【解决方案1】:

    想把这个作为一个可能的答案,答案是没有相对直接的方法来实现我所要求的。这是一种在 UITableView 页面中检测到点击或双击的方式,该页面已经在拾取行触摸和向上/向下滚动等。

    尚未验证是否是这种情况,但如果人们相信这是真的,他们可以投票赞成这个答案。

    【讨论】:

      猜你喜欢
      • 2021-07-24
      • 1970-01-01
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多