Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 5 Storyboards and Nibs

I have started my iOS 5 app using a storyboard, however if I want to programatically modally present a view, how can I? I can't use initWithNibName as there are no longer nob files, but a storyboard.

E.g. this will give me a blank UINavigationView and not my Interface Builder one:

setupView = [[setupController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:setupView];
[self presentModalViewController:navigationController animated:YES];

If I use a button in interface builder (in my storyboard) and link the two views with it using 'Modal' it works a charm, but I want to do it programatically.

Thanks.

like image 598
Josh Kahane Avatar asked Oct 19 '11 11:10

Josh Kahane


People also ask

What is a nib in iOS?

A nib file is a special type of resource file that you use to store the user interfaces of iOS and Mac apps. A nib file is an Interface Builder document.

Should I use Xib or storyboard?

BUT, if you a professional developer, you MUST use xibs for VCs, Cells, etc, Because this is the only way to make them really reusable and portable, in order to gain so much time for the next project, or even when having to make a little change or build the storyboard again.

What is storyboard and Xib in Swift?

Storyboards - this is a visual tool for laying out multiple application views and the transitions between them (segues). XIBs (or NIBs) - each XIB file corresponds to a single view element and can be laid out in the Interface Builder, making it a visual tool as well.


1 Answers

Turns out I think I have been looking for performSegueWithIdentifier and it works a charm.

like image 187
Josh Kahane Avatar answered Oct 13 '22 00:10

Josh Kahane