'automaticallyAdjustsScrollViewInsets' was deprecated in iOS 11.0

Lepidopteron picture Lepidopteron · Jun 6, 2017 · Viewed 40.4k times · Source

I just started compiling up to iOS 11 and noticed that Apple now declared the property

var automaticallyAdjustsScrollViewInsets: Bool { get set }

as being deprecated:

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621372-automaticallyadjustsscrollviewin

enter image description here

Is there another property to fix this warning in iOS 11?

Will the default value stay true or how will this be handled in future?

Answer

tangkunyin picture tangkunyin · Jul 21, 2017

This code may help:

if #available(iOS 11.0, *) {
    scrollView.contentInsetAdjustmentBehavior = .never
} else {
    automaticallyAdjustsScrollViewInsets = false
}