如何区分 UITableView 自定义部分点击和部分第一行点击? [英] How to distinguish between UITableView custom section click and section first row click?

查看:51
本文介绍了如何区分 UITableView 自定义部分点击和部分第一行点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UITableView 返回相同的回调didSelectRowAtIndexPath"和相同的 NSIndexPath (0,0),用于部分点击和部分第一行点击.我正在为节标题视图使用自定义视图,我需要对这些节行执行一些操作.尝试使用 [tableView cellForRowAtIndexPath:indexPath] 检查单元格类,但它显然返回相同的行单元格而不是节单元格.有什么建议吗?

UITableView returns the same callback "didSelectRowAtIndexPath" with the same NSIndexPath (0,0) both for section click and section first row click. I'm using custom view for section header view and I need to perform some action on these section rows. Tried checking cell class with [tableView cellForRowAtIndexPath:indexPath] but it's obviously returning the same row cell instead of section cell. Any suggestions?

UPDATE 我可以将我的自定义部分视图添加到第一行,而不是将其添加为一个部分,但是在这种情况下,我需要在heightForRowAtIndexPath",这将是不明智的决定.

UPDATE I could add my custom section view to first row instead of adding it as a section, however in that case, I would need to return different row height in "heightForRowAtIndexPath" and that would be not-performanc-wise decision.

更新我将我的剖面视图设计为 UITableViewCell 的子类,因为我更喜欢获得原生 UITableView 回调,而不是通过点击手势或按钮来解决.

UPDATE I'v designed my section view as a subclass of UITableViewCell, because I prefer to get native UITableView callbacks instead of workaround'ing with tap gestures or buttons.

推荐答案

Centurion,如果你想有一个可以轻松打开/关闭的部分,我建议你使用类 APLSectionHeaderView.您可以在 APLSectionHeaderView.hAPLSectionHeaderView.m

Centurion, if you want to have section that you open/close easily, I suggest you to use the class APLSectionHeaderView. You can find more information on APLSectionHeaderView.h and APLSectionHeaderView.m

希望能帮到你.

我一直在使用它,所以如果您对此有任何疑问...

I've been using it, so if you have some question about it...

这篇关于如何区分 UITableView 自定义部分点击和部分第一行点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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