gpt4 book ai didi

ios - 允许最后一个 UITableViewCell 滚动到第一行

转载 作者:行者123 更新时间:2023-12-01 18:56:06 25 4
gpt4 key购买 nike

通常在 UITableView 中最后一个 UITableViewCell 不允许向上滚动,我想允许最后一个 UITableViewCell 直到它到达第一行。

我知道的一种方法是向 UITableView 添加空页脚,但我无法弄清楚我需要给页脚多少空间才能允许最后一行滚动。

编辑:向 UITableView 添加空页脚 View 对我有用

最佳答案

我不确定这一点,但我认为这可能会有所帮助,具体取决于 contentInset 以及最后一个单元格高度是否未知

  -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGRect temrect=CGRectMake(0, scrollView.contentSize.height-3, scrollView.frame.size.width, 3);
// here i am expecting the height of the last row is atleast 3 and
for (UIView *temv in scrollView.subviews)
{
if (CGRectIntersectsRect(temrect, temv.frame)) // check ing for intersection
{

CGFloat bottomInset = scrollView.frame.size.height - temv.frame.size.height;
scrollView.contentInset = UIEdgeInsetsMake(0, 0 , bottomInset, 0);
break;
}
}
}

注意:如果表格 View 框架高度大于表格 View 内容大小,则不适用。仅当 temrect 参数与单元格相交时才适用

希望能帮助到你

关于ios - 允许最后一个 UITableViewCell 滚动到第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27016208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com