Fogmeister Fogmeister - 7 months ago 62
iOS Question

iOS7 UIRefreshControl changes contentInset

I have a

in my app. The
is set to opaque and all the scroll views do not overlap underneath the bar.

In one view I have a
. The frame of the
(0 0; 320 504)
on my iPhone 5. i.e. the height is 568 - 64 (the height of the nav bar and status bar).

of the
(0, 0, 0, 0)
. When the table view first loads the
(0, 0)

This is fine. Works brilliantly.

I added a
to the table view. This works a couple of times but then after a few times of doing pull to refresh then the content at the top gets "stuck" under the nav bar.

When this happens I inspect the
and it is now
(-60, 0, 0, 0)

Is there any way to stop the UIRefreshControl from changing the


This is probably the reason why UIRefreshControl is currently only supported on UITableViewController, rather than by addition to any scrollview (which you can get away with, in many cases).

The refresh control does its magic by tinkering with the content insets of the scrollview - particularly when it ends refreshing. Unfortunately the view controller is also tinkering with the content insets of the scroll view to fit it under the translucent nav and status bars. Fun ensues. Is this also an issue on iOS 6 (or, "good old iOS6" as I called it when dealing with the same issue).

The quickest solution is probably to add your table view as a child UITableViewController instead of a simple subview. I think that UITableViewController manages the insets for you at the end of the refresh. If that doesn't work, I've got workarounds for this but it will have to wait until I get back in the office.