在故事板中使用自定义推送Segue

时间:2012-10-18 14:40:02

标签: iphone objective-c ios xcode

在iPhone中,当我们在Storyboard中使用push Segue时,它始终从right导航到left。我们是否可以实施其导航leftrightdowntop的任何机制?

我知道如何创建Custom Segue,但它不像Push那样有效。你能救我吗?

1 个答案:

答案 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];
}