我有一个UINavigationController
子类,其子类如下:
func setRootVC(_ viewController: UIViewController) {
self.delegate = self
automaticallyAdjustsScrollViewInsets = false
pushViewController(viewController, animated: false)
// some more settings here
}
对于iOS 11.0及更高版本,我收到以下警告:
在iOS 11.0中不建议使用“ automaticallyAdjustsScrollViewInsets”:改用UIScrollView的contentInsetAdjustmentBehavior
在此UIScrollView
类中没有任何UINavigationController
或其子类之一。我想象automaticallyAdjustsScrollViewInsets = false
的目的是将该设置应用于推送到那里的视图控制器。但是现在,我不知道如何使用contentInsetAdjustmentBehavior
来保留以前的行为来替换它,因为那是UIScrollView
上的一个属性,而不是UIViewController
上的一个。
编辑:我在设置了UIViewController
但不具有automaticallyAdjustsScrollViewInsets = false
子视图自身属性的UIScrollView
子类中发现了类似的问题。所有这些情况的处理方法是什么?