hmthur
hmthur

Reputation: 2565

Correct way to manually add a xib file

What is the correct way to manually add a xib file i.e. if while creating the class, we uncheck "With XIB for interface"...then how do we connect both the IB & VC.m file later, to ensure that the view gets loaded from xib ?

Upvotes: 2

Views: 2240

Answers (2)

ageektrapped
ageektrapped

Reputation: 14562

To allow setting actions and outlets at design time in IB, once you create the xib file, change File Owner to your controller class. To do this, in IB, with File Owner selected, press Command-4.

Upvotes: 1

Gavin Miller
Gavin Miller

Reputation: 43815

Typically this is done when you instantiate your sub-classed UIViewController. Your call would look something like this:

MyViewController *viewController = [[MyViewController alloc] 
                                       initWithNibName:@"NibName" bundle:nil];

Checkout UIViewController initWithNibName: bundle: documentation for more details. You can also look at the documentation on Custom View Controllers for a good bit of information on sub-classing UIViewControllers.

Upvotes: 3

Related Questions