UIScrollView's origin changes after popping back to the UIViewController

后端 未结 17 2372
不知归路
不知归路 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:03

    recently , I have encountered this bug, can be solved using these codes:

    // fix ios 6 bug begin
    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7) {
            isRecoredforios6 = YES;
            recordedOffsetforios6 = self.tableView.contentOffset;
            recordedSizeforios6 = self.tableView.contentSize;
        }
    }
    
    - (void)viewDidLayoutSubviews
    {
        [super viewDidLayoutSubviews];
        if (isRecoredforios6) {
            isRecoredforios6 = NO;
            self.tableView.contentSize = recordedSizeforios6;
            self.tableView.contentOffset = recordedOffsetforios6;
        }
    }
    // fix ios 6 bug end
    

    thanks Peter Jacobs!

提交回复
热议问题