uitableview contentInset问题 [英] uitableview contentInset issue

查看:135
本文介绍了uitableview contentInset问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 contentInsent 中遇到了奇怪的问题。我正在实现Pull& release以在UITableView上刷新并且一切正常,但在某些情况下我想在没有用户交互的情况下显示加载状态。所以我想我会以下列方式简单地使用 contentInset

I have strange issue with contentInsent. I am implementing "Pull & release" to refresh on UITableView and everything works fine, but in some cases I would like to display "loading" status without user interaction. So I thought I will simply use contentInset in the following way:

scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);

显示1或2个单元格的一切正常 - 视图中可能有3个单元格。但是,一旦单元格数量增加,我的横幅顶部就不会显示,同时手动滚动工作正常。除了移动内容之外,我是否必须移动滚动条?

Everything works fine for 1 or 2 cells displayed - out of 3 possible on the view. However once the number of cells grows my banner at the top does not get displayed, at the same time manually scrolling works fine. Do I have to move the scroll besides moving content?

推荐答案

好的,所以我通过播放不同的值来找到答案。除了设置 contentInset 之外,在上述情况下,您还必须设置 contentOffset 。在我的例子中,以下代码有效:

OK, so I found the answer by playing a bit with different values. Turnes out that in the case described above besides setting contentInset you have to also setup contentOffset. In my case the following code worked:

scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);    
scrollView.contentOffset = CGPointMake(0.0f, -60.0f);

这篇关于uitableview contentInset问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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