iOS 11.0中不推荐使用“自动调整ScrollViewInsets”

我刚刚开始编译到iOS 11,并注意到苹果现在宣布的财产

var automaticallyAdjustsScrollViewInsets: Bool { get set } 

作为被弃用:

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

在这里输入图像说明

有没有另一个属性来解决这个警告在iOS 11?

默认值是否保持不变或将来如何处理?

此属性的默认值现在是true。 如果你需要设置这个,你将需要将它设置在将承载viewController的滚动视图中,并设置其属性contentInsetAdjustmentBehavior。 下面是一个例子:

 scrollView.contentInsetAdjustmentBehavior = .automatic 

此代码可能有助于:

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