“viewWillTransitionToSize:” not called in iOS 9 when the view controller is presented modally

后端 未结 4 1081
夕颜
夕颜 2021-01-01 14:44

I present a view controller from another one:

- (void)showModalView
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil];
          


        
4条回答
  •  一生所求
    2021-01-01 15:02

    Maybe it's a little late, but I put this here for anyone stumbling upon this frustrating issue.

    Keep in mind that viewWillTransitionToSize:withTransitionCoordinator: sometimes gets called on the presentingViewController of the view controller you are expecting it to. (And if that view controller has a presentingViewController too, it may get called on that)

    I couldn't really figure out the logic behind this, but that was the point in my case. So I had to override viewWillTransitionToSize:withTransitionCoordinator: in many of my view controllers like this:

    - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator {
        [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    
        [self.presentedViewController viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    }
    

提交回复
热议问题