GuybrushThreepwood
GuybrushThreepwood

Reputation: 5616

Presenting a Custom UIViewController without a NIB ? iPad

I have a view based application. I am trying to load a second custom view controller when the app starts. I have the following code :

- (void)viewDidLoad
{
controller = [NewController alloc];  

[self presentModalViewController:controller animated:YES];
[controller release];

[super viewDidLoad];

}

The problem is that the new view controller is not loading and viewDidLoad is not called. I have no xib file for the second view controller.

Can anyone help ?

Upvotes: 2

Views: 1270

Answers (2)

Ashley Mills
Ashley Mills

Reputation: 53171

You're missing a call to init your view controller...

- (void)viewDidLoad
{
    controller = [[NewController alloc] init];  

    [self presentModalViewController:controller animated:YES];
    [controller release];

    [super viewDidLoad];
}

Upvotes: 0

Eugene
Eugene

Reputation: 10045

It won't work in your viewDidLoad or viewWillAppear methods. Use viewDidAppear instead.

Upvotes: 4

Related Questions