检查 UITableViewCell 是否完全可见 [英] Check if a UITableViewCell is completely visible

查看:41
本文介绍了检查 UITableViewCell 是否完全可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查 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 的边界内(基于 contentSizecontentOffset,使用 <代码>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屋!

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