UINavigationController:如何在iOS 11+中正确替换`automaticallyAdjustsScrollViewInsets`?

时间:2019-02-22 19:13:27

标签: ios swift uiscrollview uinavigationcontroller ios11

我有一个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子类中发现了类似的问题。所有这些情况的处理方法是什么?

0 个答案:

没有答案