automaticallyAdjustsScrollViewInsets not working
For automaticallyAdjustsScrollViewInsets
to work, your view controller must be directly on a UINavigationController
's stack, i.e. not as a child view controller within another view controller.
If it is a child view controller of another view controller which is on the navigation stack, you can instead set automaticallyAdjustsScrollViewInsets = NO
on the parent. Alternatively you can do this:
self.parentViewController.automaticallyAdjustsScrollViewInsets = NO;
I just solved this issue with iOS 11 and swift 4, my current problem was that iOS11 has a new property to validate the insets when a ScrollView does exist, that one is contentInsetAdjustmentBehavior
which is a ScrollView's property and the default property is automatic
so my code was:
if #available(iOS 11, *) {
myScroll.contentInsetAdjustmentBehavior = .never
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
I hope this solve your problems too...
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.