hanumanDev
hanumanDev

Reputation: 6614

Presenting a view controller that doesn't have a nib file

How would I go about presenting a view controller that doesn't have a nib file?

I have a viewController without a nib and would like to have this view displayed when a user touches a button. Is it necessary to also have a nib file to do this?

thanks for any help.

I ended up using:

CameraViewController *cvc = [[CameraViewController alloc] init];
        [self.navigationController pushViewController:cvc animated:YES];
        [cvc release];

Upvotes: 0

Views: 750

Answers (2)

crackity_jones
crackity_jones

Reputation: 1077

You can create the view programmatically instead of inside of the nib. Then a nib would not be needed.

- (IBAction)buttonPressed:(id)sender {
CameraViewController *cameraViewController = [[CameraViewController alloc] init];
[self presentModalViewController:cameraViewController animated:YES];
}

Upvotes: 1

Brandon A
Brandon A

Reputation: 926

You don't need a nib for a view controller. In general, it can be useful to have a nib because of maintenance and other things; but if you don't want a nib you'll want to override the -loadView method provided by UIViewController.

Upvotes: 3

Related Questions