繁体   English   中英

'automaticallyAdjustsScrollViewInsets' 在 iOS 11.0 中被弃用

[英]'automaticallyAdjustsScrollViewInsets' was deprecated in iOS 11.0

我刚开始编译 iOS 11 并注意到 Apple 现在声明了该属性

var automaticallyAdjustsScrollViewInsets: Bool { get set }

被弃用:

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

在此处输入图像描述

在 iOS 11 中是否有其他属性可以修复此警告?

默认值会保持为真还是将来如何处理?

此代码可能有所帮助:

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

此属性的默认值现在为true。 如果需要设置它,则需要在将承载viewController的scrollview中设置它并设置其属性contentInsetAdjustmentBehavior。 以下是一个例子:

scrollView.contentInsetAdjustmentBehavior = .automatic

您也可以在Interface Builder中进行设置。 选择tableView或collectionView,然后从Size Inspector中的下拉列表中选择。来自'内容插入调整行为'

大小检查员

对于那些想要从 objective-c 角度进行调整的人,这里是代码:

self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM