'automaticallyAdjustsScrollViewInsets' 在 iOS 11.0 中被弃用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44390971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'automaticallyAdjustsScrollViewInsets' was deprecated in iOS 11.0
提问by Lepidopteron
I just started compiling up to iOS 11 and noticed that Apple now declared the property
我刚开始编译到 iOS 11 并注意到 Apple 现在声明了该属性
var automaticallyAdjustsScrollViewInsets: Bool { get set }
as being deprecated:
被弃用:
Is there another property to fix this warning in iOS 11?
在 iOS 11 中是否还有其他属性可以修复此警告?
Will the default value stay true or how will this be handled in future?
默认值会保持为真还是将来会如何处理?
回答by tangkunyin
This code may help:
此代码可能有帮助:
if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
回答by totiG
The default for this property is now true. If you need to set this, you will need to set it in the scrollview that would host the viewController and set its property contentInsetAdjustmentBehavior. Below is an example:
此属性的默认值现在为 true。如果您需要设置它,您需要在承载 viewController 的滚动视图中设置它并设置其属性 contentInsetAdjustmentBehavior。下面是一个例子:
scrollView.contentInsetAdjustmentBehavior = .automatic
回答by Richard Hope
You can also set this in Interface Builder. Select your tableView or collectionView then select from the drop-down in the Size Inspector select .never for 'Content Insets Adjustment Behavior'
您也可以在 Interface Builder 中进行设置。选择您的 tableView 或 collectionView,然后从 Size Inspector 的下拉列表中选择 .never for 'Content Insets Adjustment Behavior'