João Abrantes
João Abrantes

Reputation: 4883

How to do a replace segue on an iPhone?

I want to change between two view controllers using a button, on an iPhone. I don't want to use UITabBarController because it takes too much space, but I want the same kind of segue. How do I do that? Do I need to write a custom segue ?

Upvotes: 0

Views: 689

Answers (1)

John Jamieson
John Jamieson

Reputation: 101

A Push Segue is probably what you want as its operation can be reversed allowing the button (or stepper) to dictate navigation.

To initiate;

[self performSegueWithIdentifier:@"DestinationViewController" sender:self];

To return either use the back button that will appear in the navigation bar or programmatically with a hidden back button.

[self.navigationController popViewControllerAnimated:YES];

To hide the back button:

self.navigationItem.hidesBackButton = YES;

called in the -(void)viewWillAppear part of the lifecycle.

Upvotes: 1

Related Questions