处理UITableViewCell中的touchesBegan会禁用didSelectRowAtIndexPath

Mug*_*nth 7 iphone cocoa-touch uitableview

我正在我的customtableviewcell控件中实现滑动手势,因此我可以实现touchesBegan事件.我能够实现滑动,但不幸的是,因为touchesBegan在customcell中处理,我没有在tablecontroller上获得didSelectRowAtIndexPath消息.如果禁用了touchesBegan方法,则可以正常工作.

应如何处理?我希望触摸事件在处理touchesBegan后冒泡响应者链.我怎样才能做到这一点?

谢谢.

Blu*_*ame 15

我确信你可以看到这种情况正在发生,因为你重写了一个先前在超类上定义的方法.这样做意味着事件没有被调用.

你尝试过调用[super touchesBegan]吗?那样处理所有上游的东西.并且您可以覆盖滑动手势.

或者其他选项是在您自己的触摸方法中检测到触摸时调用代理.

类似的东西(你可能也会有其他触摸事件的实现)

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

  • [super touchesBegan]很可能是正确的方法. (7认同)
  • [super touchesBegan] 也帮助了我。谢谢。 (2认同)