P
P
Petrushka2015-04-17 00:27:27
Objective-C
Petrushka, 2015-04-17 00:27:27

How to switch between controllers in code?

Good day, sorry for such a banal question, but I'm confused
In general, let's say I have 2 controllers, one of them is the root for the navigator controller, how do we plant when the button is pressed, switch to the 2nd controller?
I do it like in the lessons, but the program flies or something else
(I added a header)

SecondCont * sec=[[SecondContalloc alloc] initWithNibName:@"???" bundle:nil];

[self.navigationController pushViewController:sec animated:YES];

what to write in 1 parameter? to define it somewhere in the storyboard?
and when I put nil there, I turn to the black screen
Navigation bar auto will be added for 2 contacts? or how

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
ManWithBear, 2015-04-17
@petruska

Don't forget to put the correct identifier in IB

YourViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerIdentifier"];
[self.navigationController pushViewController:vc animated:YES];

Nib
Storyboard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question