开发者

uitableview contentInset issue

开发者 https://www.devze.com 2023-03-22 05:32 出处:网络
I have strange issue with contentInsent. I am implementing \"Pull & release\" to refresh on UITableView and everything works fine, but in some cases I wou开发者_运维技巧ld like to display \"loadin

I have strange issue with contentInsent. I am implementing "Pull & release" to refresh on UITableView and everything works fine, but in some cases I wou开发者_运维技巧ld 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);

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?


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);


this gives better results:

CGFloat offset = scrollView.contentOffset.y;
scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
scrollView.contentOffset = CGPointMake(0, offset);
0

精彩评论

暂无评论...
验证码 换一张
取 消