我的应用程序中有一个滚动视图,当我滚动到滚动视图的最后一页时,我被绑定到 tableviewcontroller。
但是为了在从滚动视图跳转到表格视图控制器时实现“类似动画的分页”,我扩展了 UIStoryboardSegue 类并实现了如下执行方法:
- (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);
}
];
}
当用户处于 UIInterfaceOrientationPortrait 方向时,它就像一个魅力。但是当我切换到 UIInterfaceOrientationLandscapeLeft 或 right 时,我无法让它工作。
我在这里基本上想做的是执行segue,所以看起来tableviewcontroller从左侧进入主屏幕(而不是从顶部或底部,因为它是默认行为),就像上面的代码适用于正常方向一样。我想象的解决方案是这样的:
- (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);
}
}
];
}
但我更难的是,任何帮助都会得到帮助。
问题更新:
我现在试过了:
- (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];
}
我收到以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'