Reputation: 21
When the user clicks the button "next", it has to hide the descriptionTextOutlet and show the datePicker (It´s Ok). But if the user click again the "next" button, my program has to show another View Controller. How can i program a segue to show my other View Controller?
-(IBAction)next:(id)sender{
if (cont==0){
self.descriptionTextOutlet.hidden=YES;
self.datePicker.hidden=NO;
cont=1;
} else {
//What do i have to write here?
}
}
Thanks for your help
Upvotes: 0
Views: 70
Reputation: 215
If you are using Navigation controller and want to push viewcontroller then
UIStoryboard * sb = [UIStoryboard storyboardWithName:@"storyboard_name" bundle:[NSBundle mainBundle]];
ViewController * view = [sb instantiateViewControllerWithIdentifier:@"id_of_your_storyboard"];
[self.navigationController pushViewController:view animated:YES];
And if you want to only present viewcontroller
UIStoryboard * sb = [UIStoryboard storyboardWithName:@"storyboard_name" bundle:[NSBundle mainBundle]];
ViewController * view = [sb instantiateViewControllerWithIdentifier:@"id_of_your_storyboard"];
[self presentViewController:view animated:YES completion:nil];
What this code do:
1) load storyboard from your main bundle (storyboard_name)
2) find view controller from your storyboard with given identifier (id_of_your_storyboard)
3) present or push that view controller
storyboard_name -- Name of your story board
id_of_your_storyboard -- storyboard id in identity inspector
Upvotes: 0
Reputation: 1767
You need to declare the segue and then call it. Something like the code below:
YourNextViewController *nextVC = [[YourNextViewController alloc] init];
[self presentModalViewController:nextVC animated:YES];
Don't forget to thumb up if that was helpful to you
Upvotes: 3