Vishnu
Vishnu

Reputation: 2243

UInavigation Controller not working from switching view controller to tableviewcontroller

I'm trying to implement UInavigation controller to switch views from view controller to table view controller.Here is my code.

-(IBAction)product:(id)sender
{
Products *second=[[Products alloc]init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:second];

nav.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;

[self.navigationController pushViewController:second animated:YES];

}

But i'm not getting it..Am i missing anything..

Upvotes: 0

Views: 107

Answers (1)

Stavash
Stavash

Reputation: 14304

First of all, make sure "Products" is a subclass of UIViewController. If it's a view controller subclass with a .XIB file, instantiate it using "initWithNibName", not alloc & init:

Products *second = [[Products alloc] initWithNibName:"YourXibFileName.xib" bundle:[NSBundle mainBundle]];

The second issue here is that you instantiate a UINavigationController for no reason - remove this line and just stay with self.navigationController.

Upvotes: 1

Related Questions