检查 UITableViewCell 是否完全可见 [英] Check if a UITableViewCell is completely visible
问题描述
如何检查 UITableViewCell 是否在屏幕上完全可见(没有被选项卡或导航栏截断)?
How can I check if a UITableViewCell is completely visible on the screen (not cut off by the tab or nav bar)?
我可以使用此代码获取可见单元格:
I can get the visible cells with this code:
NSArray *indexes = [_tableView indexPathsForVisibleRows];
但我想排除屏幕中不完全可见的单元格.
but I want to exclude cells that are not entirely visible in the screen.
推荐答案
如您所见,获取可见单元格.唯一可能不完整的是顶部和底部的.对于每个,检查它的 rect (rectForRowAtIndexPath:
) 是否完全在 table view 的边界内(基于 contentSize
和 contentOffset
,使用 <代码>CGRectContainsRect).
As you have, get the visible cells. The only ones that might be partial are the top and bottom ones. For each, check if its rect (rectForRowAtIndexPath:
) is fully within the bounds of the table view (based on contentSize
and contentOffset
, using CGRectContainsRect
).
这篇关于检查 UITableViewCell 是否完全可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!