UITableViewController select header for section(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 做到这一点.
No there is no way to do it with the 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 选择部分的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UITableViewController 选择部分的标题
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
