uitableviewcontroller选择标题 [英] uitableviewcontroller select header for section

查看:77
本文介绍了uitableviewcontroller选择标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个部分的UITableView。每个部分都有一个部分标题(自定义视图)是否有一种简单的方法可以检测到有人选择部分标题? (就像didSelectRowAtIndexPath,但是对于标题?)

I have a UITableView with multiple sections. Each section has a section header (a custom view) is there an easy way to detect when someone selects the section header? (Just like didSelectRowAtIndexPath, but for the header?)

提前致谢。

推荐答案

没有办法用 UITableViewDelegate 来做。

你可以做的是添加部分标题视图大小的按钮并将其添加到视图中。将按钮的标记设置为节索引。
然后只需添加 UIViewController 作为 UIControlEventTouchUpInside 的目标。

What you can do is to add a button the size of the section header view and add it to the view. Set the tag of the button to the section index. Then just add the UIViewController as a target for the UIControlEventTouchUpInside.

然后通过查看按钮的标签,您可以看到点击了哪个部分。

Then by looking at the tag of the button you can see which section is clicked.

这篇关于uitableviewcontroller选择标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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