UIScrollView's origin changes after popping back to the UIViewController

后端 未结 17 2325
不知归路
不知归路 2020-12-07 16:50

I have a UIViewController subclass as a scene in the storyboard that contains a UIScrollView containing various subviews. One of the subviews is a

17条回答
  •  無奈伤痛
    2020-12-07 17:10

    I'm using a collectionView and I had a similar problem. For iOS 11: in the size inspector, there is "content inset". Set that to "Never". That solved the problem for me. I hope this helps someone.

    Objective C:

    if (@available(iOS 11, *)) {
       [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    

    Swift:

    if #available(iOS 11, *) {
    UIScrollView.appearance().contentInsetAdjustmentBehavior = .never
    }
    

提交回复
热议问题