处理touchesBegan在UITableViewCell禁用didSelectRowAtIndexPath [英] Handling touchesBegan in UITableViewCell disables didSelectRowAtIndexPath

查看:585
本文介绍了处理touchesBegan在UITableViewCell禁用didSelectRowAtIndexPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的customtableviewcell控件中实现滑动手势,所以我hvae实现touchesBegan事件。
我能够实现滑动,但不幸的是,因为touchesBegan在customcell中处理,我没有得到一个didSelectRowAtIndexPath消息在tablecontroller。如果touchesBegan方法被禁用,它会工作。



如何处理?我想触摸事件在处理touchesBegan后响应链。

解决方案

我确保你可以看到这是发生,因为你覆盖了一个以前在超类上定义的方法,这样做意味着事件不被调用。



你试过调用[super touchesBegan],这样处理所有上游的东西,你可以覆盖滑动手势。



或者另一个选项是调用委托当您以自己的触摸方法检测到触摸时。



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

   - (void)touchesBegan 
{
//只检测tap的逻辑
[tablecell.delegate didSelectRowAtIndexPath:方式确定被触摸的行)]
}


I'm implementing swipe gestures in my customtableviewcell control and so I hvae to implement touchesBegan event. I'm able to implement the swipes, but unfortunately, because the touchesBegan gets handled in the customcell, i'm not getting a didSelectRowAtIndexPath message on the tablecontroller. If the touchesBegan method is disabled, it works.

How should this be handled? I want the touch event to bubble up the responder chain after the touchesBegan is processed. How can I do this?

Thanks.

解决方案

I"m sure you can see that this is happening because you are overriding a method that was previously defined on a super class. and by doing so means that the events are not being called.

have you tried calling [super touchesBegan]? that way all upstream stuff is handled. and you can override the swipe gesture.

or another option is to call the delegate when the touch is detected in your own touches method.

something like (you will probably have implementations of the other touch events as well)

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

这篇关于处理touchesBegan在UITableViewCell禁用didSelectRowAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆