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 - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
