automaticallyAdjustsScrollViewInsets not working

I think that automaticallyAdjustsScrollViewInsets only works when your controllers view is a UIScrollView (a table view is one).

You’re problem seems to be that your controller’s view is a regular UIView and your UITableView is just a subview, so you’ll have to either:

  • Make the table view the “root” view.

  • Adjust insets manually:

    UIEdgeInsets insets = UIEdgeInsetsMake(controller.topLayoutGuide.length,
                                           0.0,
                                           controller.bottomLayoutGuide.length,
                                           0.0);
    scrollView.contentInset = insets;
    

Edit:

Seems like the SDK is capable of adjusting some scroll views despite not being the controller’s root view.

So far It works with UIScrollView‘s and UIWebView‘s scrollView when they are the subview at index 0.

Anyway this may change in future iOS releases, so you’re safer adjusting insets yourself.

Leave a Comment