开发者

uitableview contentInset issue

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜