作者:mobiledu2502904157 | 来源:互联网 | 2023-02-01 23:38
我刚刚开始编译到iOS 11,并注意到Apple现在宣布该属性
var automaticallyAdjustsScrollViewInsets: Bool { get set }
被弃用:
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621372-automaticallyadjustsscrollviewin
是否有其他属性可以在iOS 11中修复此警告?
默认值是否保持正确或将来如何处理?
1> 小智..:
此代码可能有所帮助:
if #available(iOS 11.0, *) {
scrollView.cOntentInsetAdjustmentBehavior= .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
@AlexeyStrakh scrollView是任何调整了插图的`UIScrollView`.例如,在`UICollectionViewController`上它将是`self.collectionView`,在`UITableViewController`上它将是`self.tableView`.
2> totiG..:
此属性的默认值现在为true.如果需要设置它,则需要在将承载viewController的scrollview中设置它并设置其属性contentInsetAdjustmentBehavior.以下是一个例子:
scrollView.cOntentInsetAdjustmentBehavior= .automatic
虽然我使用".never"因为我把它设置为假,这个似乎是正确的替代品!谢谢.