Reputation: 7959
I have 2 separate TableViewControllers. At one particular instance I would like to be able to load a ViewController which will place a SegmentedControl in the NavigationController...which in turn will load the appropriate TableViewController.
Currently I have the SegmentedControl just pushishing the correct TableViewController and it works fine if I manually initiate the push. However if I try to do the push anytime before ViewDidAppear, the pushed TableViewController wont display anything..it will trace things ok though.
And just to note, the 2 TableViewConrollers are both different enough that I can't just use one Controller and just switch the dataSource.
Any suggestions ?
Upvotes: 0
Views: 655
Reputation: 7959
I actually figured out a better solution for my problem, so if anyone is interested ...
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
[viewController viewWillAppear:animated];
}
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
[viewController viewDidAppear:animated];
}
Bam, you got yourself a UINavigationController inside a UINavigationController>viewController
Upvotes: 1
Reputation: 21882
Instead of pushing the table view controllers to the nav controller, you probably want to have a view controller that contains the two table controllers. Then, add one of the table views as a subview of the view controller's view. I.e. when the segmented controller is switched, you do something like:
[self.tableController1.view removeFromSuperview];
[self.view addSubview self.tableConttroller2.view];
You'll probably also have to send the appropriate view[Will/Did][Appear/Disappear]
messages to your table controllers to make sure they're initialized properly.
Upvotes: 1