I have a view controller that I am presenting with the following objective c code:
CATransition *animation=[CATransition animation];
animation.delegate=self;
animation.duration=0.3;
animation.type=kCATransitionMoveIn;
animation.subtype=kCATransitionFromRight;
[self presentViewController:reader animated:NO completion:nil];
[reader.view.layer addAnimation:animation forKey:@"animation"];
and dismissing with similar code inside a delegate method
CATransition *animation=[CATransition animation];
animation.delegate=self;
animation.duration=0.3;
animation.type=kCATransitionMoveIn;
animation.subtype=kCATransitionFromLeft;
[self dismissViewControllerAnimated:NO completion:nil];
[self.view.layer addAnimation:animation forKey:@"animation"];
However there is one problem: unlike using a navigation controller where you see one view slide onto other view; here the old view just disappears instantly so the new view moves onto a blank view.
How do I fix this problem? I need this code to work in IOS 6,7 and 8 and would like it to look like the horizontal animation you see when going back and forth between views that are inside navigation controllers.
Edit: The solution I accepted has a bug with iOS 6, if I can find a solution that fixes it, I'll edit this post.
Edit 2: Found it. It appears that since I am presenting a zBar view controller I need to use this code
zbarController.wantsFullScreenLayout=NO;
after I set the cameraOverlayView.
Presenting a view controller using a custom animation:
Dismissing a view controller using a custom animation: