Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Custom Push Segue in Storyboard

In iPhone, when we use push Segue in Storyboard, it always navigates from right to left. Can we implement any mechanism that it navigates left to right, or down to top?

I know about how to create Custom Segue, but it does not work the same like Push. Can you help me?

like image 698
Ali Avatar asked Oct 18 '12 14:10

Ali


People also ask

How do I use segue in Xcode?

Open Main. storyboard and select the segue named Show segue to “Choose Game”. Then from the Attributes inspector change its Identifier to PickGame. If the segue's identifier is PickGame, cast the destination view controller as GamePickerViewController so you can access its properties.

How do I create a segue identifier?

Assigning an identifier for the segue:Select the segue, from the attribute inspector you'll see "Identifier" text field, that's it! make sure to insert the exact same name that used in performSegueWithIdentifier .


1 Answers

If you are developing an App for iOS 5, you can create a class that implement UIStoryboardSegue (to have custom segue), and then override the Perform method in this way:

-(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];
}
like image 159
Ali Avatar answered Oct 10 '22 05:10

Ali