When a user presses a logout button inside another view controller, I use notification center to fire a selector in app delegate. I want the fired method to animate a flip back to the login view controller in the app delegate.
Here is my first attempt:
LoginViewController *loginController = [[LoginViewController alloc] init];
[UIView transitionFromView:self.window.rootViewController.view
toView:loginController.view
duration:3.0f
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished){
self.window.rootViewController = loginController;
}];
This does not work, as the rootViewController gets set instantaneously with no animation.
Here is my second attempt (as referenced here: RootViewController Switch Transition Animation)
[UIView transitionWithView:self.window
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ self.window.rootViewController = [[LoginViewController alloc] init]; }
completion:nil];
This almost works, but the animation is very buggy - you can see misplaced views, stretched elements, etc during the animation and it's clear that it's not animating like you'd expect.
Any idea what the right way to do this animation is?