user1188650
user1188650

Reputation: 45

Pushing UIViewController in navigationcontroller shows empty view

I am facing the problem that when I push my viewcontroller in the navigationcontroller all it does is changing the navigationbar and showing the standard background but no view is to be seen. My code for pushing the viewcontroller into the navigationcontroller looks like:

Viewcontroller1 *viewController = [[Viewcontroller1 alloc] autorelease];
[[self navigationController] pushViewController:viewController animated:YES];

But, if I initialise the viewcontroller by creating IBOutlets for it, it works just fine. But the reason why I am not doing that is because I later on needs to pass some parameters to the class on initialization.

Thanks for your time.

Upvotes: 2

Views: 4136

Answers (1)

Hiren
Hiren

Reputation: 12780

You have to initialise your view like

if you have xib then

Viewcontroller1 *viewController = [[[Viewcontroller1 alloc] initWithNibName:@"Viewcontroller1" bundle:nil]autorelease];
[[self navigationController] pushViewController:viewController animated:YES];

if you haven't xib

Viewcontroller1 *viewController = [[[Viewcontroller1 alloc] init]autorelease];
[[self navigationController] pushViewController:viewController animated:YES];

Upvotes: 3

Related Questions