UIScrollView wrong offset with Auto Layout

前端 未结 7 976
逝去的感伤
逝去的感伤 2020-12-12 22:19

I have a fairly simple view configuration:

A UIViewController, with a child UIScrollView and a UIImageView in this UIScr

7条回答
  •  無奈伤痛
    2020-12-12 22:43

    Looks like the problem solved with the dispatch_async during the viewWillAppear:

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    
        CGPoint originalContentOffset = self.scrollView.contentOffset;
        self.scrollView.contentOffset = CGPointZero;
    
        dispatch_async(dispatch_get_main_queue(), ^{
            self.scrollView.contentOffset = originalContentOffset;
        });
    }
    

提交回复
热议问题