敲击UITableViewCell的子视图时引发选择事件(didSelectRowAtIndexPath) [英] Raise selection event (didSelectRowAtIndexPath) when subview of UITableViewCell is tapped

查看:61
本文介绍了敲击UITableViewCell的子视图时引发选择事件(didSelectRowAtIndexPath)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义UITableViewCell,其中包含许多子视图。在大多数情况下,我希望UITableViewCell的控制器处理事件。在一种情况下,我希望子视图只是将事件传递给父UITableViewCell,这将导致它在分配的委托上调用didSelectRowAtIndexPath。

I've created a custom UITableViewCell that includes a number of subviews. In most cases I want the controller for the UITableViewCell to handle the events. In one case I want the subview to simply pass on the event to the parent UITableViewCell which will cause it to invoke didSelectRowAtIndexPath on the assigned delegate.

换句话说:我希望子视图变为事件透明-我希望事件通过/通过它并在基础单元格中注册。

To put it another way: I want the subview to become "event transparent" -- I want events to pass over / through it and register with the underlying cell.

有什么建议吗?用其他语言,我会提出一个事件。是Objective-C和Cocoa的新功能,尚无法在Google上找到答案。

Any suggestions? In other languages I would raise an event. New to Objective-C and Cocoa and haven't been able to google up an answer yet.

提前感谢。

推荐答案

尝试将视图的 userInteractionEnabled 属性设置为 NO

Try setting your view's userInteractionEnabled property to NO.

这将使其忽略所有触摸事件,然后其下的视图将能够捕获这些事件。

This will make it ignore all touch events, and then the views under it will be able to catch these events.

这篇关于敲击UITableViewCell的子视图时引发选择事件(didSelectRowAtIndexPath)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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