I’m trying to replace the window rootViewController with animation and it only works partially.
I create a UINavigationController programatically –
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"InboxStoryboard" bundle:nil];
UIViewController *innerViewController = [storyBoard instantiateViewControllerWithIdentifier:@"centerView"];
UINavigationController *centerView = [[UINavigationController alloc] initWithRootViewController:innerViewController];
Afterwards I replace the window root view controller wrapped in an animation block –
[UIView transitionWithView:self.viewController.view.window
duration:0.5
options: UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
self.viewController.view.window.rootViewController = centerView;
}
completion:nil];
What happens is that the animation happen but the controller that I create is only partially visible, take a look at the following picture –
So as you can see during the rotation the view is only partially rendered.
Anyone bumped into this kind of behaviour before?


So after a long search I found the problem was in the
[UIView transitionWithView:...]Searching a bit more in stackoverflow I found Swapping rootViewController with animation
Using
[UIView transitionFromView:..]works perfectly.The new code –