IOS - How to program the navigation between ViewController in Objective-C?

0

I want to navigate between the ViewController of an app by clicking a button and switching from one to another for example. But I did not want to do this for the .storyboard, I want to do it directly via code. It's possible? If so, how can I do it?

    
asked by anonymous 19.02.2016 / 19:08

1 answer

1

You can use the pushViewController: or presentViewController: ". First you need to get an instance of your UIViewController that will open and that is on the storyboard via the identifier:

SegundaViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"segundaView"];

Now you do the push from navigationController :

[[self navigationController] pushViewController:viewController animated:YES];

Or open as a modal:

[self presentViewController:viewController animated:YES completion:nil];
    
19.02.2016 / 19:30