I present a view controller from another one:
- (void)showModalView
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MySecViewController *mySecViewController = [storyboard instantiateViewControllerWithIdentifier:@"secController"];
mySecViewController.delegate = self;
[self presentViewController:mySecViewController animated:YES completion:nil];
}
Then in the presented UIViewController
, the method viewWillTransitionToSize:withTransitionCoordinator:
is called in iOS 8
but not in iOS 9
...
Thanks
People have already explained that you have to call super. I'd like to add a piece of information that might help people who would have faced what i faced.
Scenario: Parent -> Child (viewWillTransition not called in child)
If your view controller is a child view controller, then check if the parent view controller delegate is called and if super is called there. Otherwise it won't be propagated to the child view controller!
P.S - This happened to me because i did not write the code for the parent.
In your current view controller, if you override
viewWillTransitionToSize:withTransitionCoordinator:
, make sure you callsuper
. Otherwise, this message won't get propagated to children view controllers.For Objective-C:
And Swift:
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 thepresentingViewController
of the view controller you are expecting it to. (And if that view controller has apresentingViewController
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:May seem a trivial case, but when using an iPad check that the user has not activated rotation lock in the settings or control panel or side button