Question

My app has two tabs that displays different information. I want it such that only the content in the table view change when i tap on different tabs and the rest all remain the same. i.e. a common navigation controller to both the tabs. This is mainly because both the tabs include almost same mechanism except for a few that can be easily differentiated in some way. By doing so a lot of rewriting of code can be avoided and moreover it will be more efficient.

Can someone suggest me something that will back my requirement?

Thanks.

Was it helpful?

Solution

I hope that you want to reuse single instance of your view controller across tabs. This is not possible. For each tab if you want to use same view controller, you have to use different objects.

eg:-

UITabBarController *tabViewController = [[UITabBarController alloc]init];
tabViewController.viewControllers = [NSArray arrayWithObjects: [[ICViewController alloc] initWithNibName:@"ICViewController" bundle:nil],[[ICViewController alloc] initWithNibName:@"ICViewController" bundle:nil], nil];
self.window.rootViewController = tabViewController;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top