iPad orientation notifications lost when transition for keyWindow
-
29-09-2019 - |
Question
I have an animation done over the keyWindow of the app.
[UIView beginAnimations:kAnimationLogin context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window_ cache:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[window_ addSubview:splitViewController_.view];
[UIView commitAnimations];
[loginViewController_.view removeFromSuperview];
This works ok. Then, if the user logouts, the transition is the reverse
[UIView beginAnimations:kAnimationLogout context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window_ cache:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[window_ addSubview:loginViewController_.view];
[UIView commitAnimations];
[splitViewController_.view removeFromSuperview];
Here is the problem. Now, loginViewController_ and splitViewController_ don't receive the orientation notifications. Why?
Solution
Well, it's not a great solution but I've found a way to avoid that problem. First of all, I think that the problem comes because, while animation, both view controllers receives the orientation notifications while, I guess, adding and removing to and from the window and raises the problem. I don't know exactly if it's an issue related to view hierarchy (I guess it's correct but I'm not sure) or not.
So, the solution I use is to put the LoginViewController as a ModalViewController of SplitViewController, that is the main controller, and use a FlipHorizontal transition while showing.
That solves the problem.