iOS 9: Frame no longer set in viewWillAppear after UINavigationController pushViewController

前端 未结 4 1247
我寻月下人不归
我寻月下人不归 2020-12-15 07:32

I\'m trying to solve a view placement bug that has arisen as of iOS 9. I am instantiating a view controller from a xib file (non-autolayout) and then pushing this onto my

4条回答
  •  别那么骄傲
    2020-12-15 07:51

    I am also looking for the best fix.

    My temporary one is to call the code that was in "viewDidAppear" in "viewDidLayoutSubviews". That way, my code will get called as soon as the frames are set.

    But, make sure to add a boolean or something so that your code doesn't get called every time viewDidLayoutSubviews is called

    -(void)viewDidLayoutSubviews{
       if (didLayoutSubviews == NO){
           didLayoutSubviews = YES;
           // perform code that was in viewWillAppear
       }
    }
    

提交回复
热议问题