【问题标题】:Handling touchesBegan in UITableViewCell disables didSelectRowAtIndexPath在 UITableViewCell 中处理 touchesBegan 会禁用 didSelectRowAtIndexPath
【发布时间】:2009-05-31 14:47:11
【问题描述】:

我正在我的 customtableviewcell 控件中实现滑动手势,因此我需要实现 touchesBegan 事件。 我能够实现滑动,但不幸的是,因为 touchesBegan 是在 customcell 中处理的,所以我没有在 tablecontroller 上收到 didSelectRowAtIndexPath 消息。如果 touchesBegan 方法被禁用,它可以工作。

应该如何处理?我希望在处理 touchesBegan 后,触摸事件在响应者链中冒泡。我该怎么做?

谢谢。

【问题讨论】:

    标签: iphone cocoa-touch uitableview


    【解决方案1】:

    我确定您可以看到这种情况正在发生,因为您正在覆盖之前在超类上定义的方法。这样做意味着不会调用事件。

    您是否尝试过调用 [super touchesBegan]?这样所有上游的东西都被处理了。并且您可以覆盖滑动手势。

    或者另一种选择是在您自己的 touches 方法中检测到触摸时调用委托。

    类似(您可能还会实现其他触摸事件)

    -(void) touchesBegan
    {
     //logic to detect tap only.
     [tablecell.delegate didSelectRowAtIndexPath:(some way to determin touched row)]
    }
    

    【讨论】:

    • 没问题,你用的是什么方法?也将不胜感激答案点
    • [super touchesBegan] 也帮助了我。谢谢。
    猜你喜欢
    • 2012-05-25
    • 2014-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 1970-01-01
    相关资源
    最近更新 更多