如何将触摸事件捕获到UITableView节标题? [英] How can I catch touch events to a UITableView section header?

查看:130
本文介绍了如何将触摸事件捕获到UITableView节标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的UITableView节标题(通过viewForHeaderInSection)实现了自定义视图。当处于普通视图模式时,默认行为似乎是单元格漂浮在节标题下方,而触摸事件通过下面的单元格。

I've implemented a custom view for my UITableView section headers (via viewForHeaderInSection). When in plain view mode, the default behavior seems to be that the cells float underneath the section headers and touch events fall through to the cells underneath.

如何让自定义区段标题视图首先对其边界内的任何触摸事件做出响应,并采取一些操作,而不是将事件传递到节标题下的单元格查看?

How can I have the custom section header view respond first to any touch events inside its bounds and take some action, rather than passing the event to the cell underneath the section header view?

推荐答案

使用UIControl而不是UIView与

Use an UIControl instead of an UIView with

[aControl addTarget:<target> action: @selector(<desiredSelector:>) forControlEvents:UIControlEventTouchUpInside];

这篇关于如何将触摸事件捕获到UITableView节标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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