Preventing UINavigationController transitions animating upwards with an offset in iOS 11?

Viewed 873

I'm updating an app from iOS 10 to iOS 11 with an iOS 9 target and this happens on every segue animation when a navigation bar is involved.

The animation starts with a small offset lower than the height it should be at and then moves to the proper height by the time the view has finished animating.

I'm not doing anything special to the navigation controllers, and it happens to each one in the app. If I programatically hide the navigation bar, the transitions animate normally.

2 Answers

Setting the tableView.contentInsetAdjustmentBehavior to .never in a UINavigationController fixes the problem.

Edit: Actually a better solution is to activate the Under Opaque Bars option for the TableViewController instead.

Otherwise the vertical scroll bars will be behind the iPhone X notch in landscape mode. This worked for me, because I use opaque bars. I don't know what happens if you use translucent bars.

enter image description here


The original solution is described by Prince on the Apple Developer Forums:

After some research ...I found that automaticallyAdjustsScrollViewInsets is deprecated in iOS 11, Now we are to use contentInsetAdjustmentBehavior in UIScrollView type views instead. Setting contentInsetAdjustmentBehavior to .never worked and also the 'UINavigationController translation slide up issue' wouldn't happen if the UINavigationBar is transulcent where the view is under the bar. (Thus the new way of doing the automaticallyAdjustsScrollViewInsets`)

This is not good for Storyboard users because this will have to be done in code.

Related