在iPhone中,当我们在Storyboard中使用push Segue时,它始终从right
导航到left
。我们是否可以实施其导航left
至right
或down
至top
的任何机制?
我知道如何创建Custom
Segue,但它不像Push
那样有效。你能救我吗?
答案 0 :(得分:12)
如果您正在开发适用于iOS 5的App,您可以创建一个实现UIStoryboardSegue的类(具有自定义segue),然后以这种方式覆盖Perform
方法:
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}