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);
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?
A view that presents data using rows in a single column.
The contentInset is how much the content is visually inset inside the scroll view. It is the custom distance that the content view is inset from the safe area or scroll view edges. contentInset allows you to specify margins or padding around the content in the scrollview.
Smooth Scrolling:- As a result, it affects the smoother scrolling experience. In UITableVIew, Scrolling will be smooth through cell reuse with the help of prepareForReuse() method.
Explaination of contentOffset of a UITableView : For example, if you have a table view of height 100. Its content may be more than it's view, say 150. contentOffset will tell the table from where in the content to start from. Say contentOffset = (0, 40) , the content will be shown after 40 of it's height.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With