Uitableview contentInset issue

I have a strange problem with contentInsent . I implement "Pull and release" to update the UITableView, and everything works fine, but in some cases I would like to display the status of the "download" without user interaction. So I thought I was just using contentInset as follows:

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

Everything works fine to display 1 or 2 cells - out of 3 possible in appearance. However, as soon as the number of cells grows, my banner at the top does not appear, while manual scrolling works fine. Do I need to move the scroll besides moving the contents?

+8
ios uitableview
source share
2 answers

OK, so I found the answer by playing a little with different values. It turns out that in the case described above, in addition to setting the contentInset , you must also set the 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); 
+31
source share

This gives the best results:

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

All Articles