I have scrollview in my application, and the second I scroll to the last page of my scrollview, which I separate from tableviewcontroller.
But to achieve "paging animation" when moving from scrollview to a table view controller, I expanded the UIStoryboardSegue class and implemented this method:
- (void) perform { UIViewController *src = (UIViewController *) self.sourceViewController; UIViewController *dst = (UIViewController *) self.destinationViewController; src.view.transform = CGAffineTransformMakeTranslation(0, 0); dst.view.transform = CGAffineTransformMakeTranslation(320, 0); [UIView animateWithDuration:0.3 animations:^{ [src presentModalViewController:dst animated:NO]; src.view.transform = CGAffineTransformMakeTranslation(320, 0); dst.view.transform = CGAffineTransformMakeTranslation(0, 0); } ]; }
And it works like a charm when the user is in the UIInterfaceOrientationPortrait orientation. But when I switch to UIInterfaceOrientationLandscapeLeft or right, I cannot get it to work.
What I basically want to do here is to do a segue, so it looks like the tableviewcontroller element is entering from the left side of the main screen (not top or bottom, as this is the default behavior) as the code above works for normal orientation. I assumed that the solution would be this:
- (void) perform { UIViewController *src = (UIViewController *) self.sourceViewController; UIViewController *dst = (UIViewController *) self.destinationViewController; if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){ }else{ src.view.transform = CGAffineTransformMakeTranslation(0, 0); dst.view.transform = CGAffineTransformMakeTranslation(320, 0); } [UIView animateWithDuration:0.3 animations:^{ [src presentModalViewController:dst animated:NO]; if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){ }else{ src.view.transform = CGAffineTransformMakeTranslation(320, 0); dst.view.transform = CGAffineTransformMakeTranslation(0, 0); } } ]; }
But itβs more difficult, although Iβm still helping.
question:
I tried this now:
- (void) perform { UIViewController *src = (UIViewController *) self.sourceViewController; UIViewController *dst = (UIViewController *) self.destinationViewController; [UIView transitionWithView:src.navigationController.view duration:0.3 options:UIViewAnimationTransitionFlipFromRight animations:^{ [src.navigationController pushViewController:dst animated:YES]; } completion:NULL]; }
I get the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'