简体   繁体   English

增加UITableView上的可点击区域

[英]Increase tappable area on UITableView

I'm testing a new iPhone app with my end-users and found that a lot of times they misses the clickable area of a UITableCell and perform the wrong action. 我正在与最终用户一起测试新的iPhone应用程序,发现很多时候他们错过了UITableCell的可点击区域并执行了错误的操作。 (Some users never before use any kind of computer!). (某些用户从未使用过任何类型的计算机!)。

Then I try myself and found that still I can fail sometimes. 然后我自己尝试一下,发现有时候我仍然会失败。 So I wonder how increase the tappable area of the cell with accessoryType = UITableViewCellAccessoryDetailDisclosureButton 所以我想知道如何使用accessoryType = UITableViewCellAccessoryDetailDisclosureButton增加单元的可点击区域

I try reducing the width of the contenview but still fail. 我尝试减小contenview的宽度,但仍然失败。 I think is necesary hit exactly thw blue arrow to hit it. 我认为必须完全按下蓝色箭头才能将其击中。

I want something like the last 1/4 of the cell be the hit area. 我希望像单元格的最后1/4这样的区域成为命中区域。

This thread has a pretty good block of code showing how to do it. 该线程有一个不错的代码块,显示了如何执行此操作。 Read down to the comments; 阅读评论; the code in the blog post itself is not correct. 博客文章中的代码本身不正确。 (This link is no longer valid.) (此链接不再有效。)

The key is to overload -hitTest:withEvent: for the UITableViewCell. 关键是要为UITableViewCell重载-hitTest:withEvent: You will be passed a point, and you can then return any view you want as the view that is being touched. 您将获得一个点,然后您可以返回任何想要的视图作为被触摸的视图。

For fun, you might try changing the frame of the accessory view and seeing what happens. 为了娱乐,您可以尝试更改附件视图的框架并查看会发生什么。 I doubt this will work as well as the -hitTest:withEvent: overload, but it's so easy that it's worth trying. 我怀疑这是否会和-hitTest:withEvent:重载一样-hitTest:withEvent: ,但是它是如此简单以至于值得尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM