开发者

Table cell only is highlighted when you tap on the disclosure icon

开发者 https://www.devze.com 2023-04-12 09:52 出处:网络
I place a single table view cell on my view using interface builder and add an accessory type, a selection color and enable user interaction.

I place a single table view cell on my view using interface builder and add an accessory type, a selection color and enable user interaction.

Table cell only is highlighted when you tap on the disclosure icon

My problem is that the cell only is highlighted when the user taps on the arrow icon. But it also should be highlighted when the user taps on the text label inside it, he can tap anywhere on the开发者_Python百科 cell.

How can I achieve this?


A UITableViewCell is really only meant to be used within the context of a UITableView (which knows how to handle and/or delegate the selection & highlighting of the cell).

Having a UITableViewCell outside of the context of a table is a somewhat unexpected user interface.

Couldn't you do what you want to do with a UIButton instead?

Or a UIView that has two UIButton subviews (or at least one UIButton subview to contain a widget graphic that looks like the disclosure accessory)? That way the things you want to get highlighted would definitely happen, as opposed to depending on a nonexistent [UITableView didSelectCellAtIndexPath:] method that doesn't exist in a view that isn't a UITableView delegate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号