Reputation: 601
I have a TabBar iPad app with a Split Controller in first tab. I follow this instructions to make it:
Now my goal is to hide the root view controller of the split controller. I found a method to accomplish this:
But that doesn't works for me, because it only works assuming the split controller is in the MainWindow.xib. But with the previous method, the split controller is added programatically.
Can someone help me to get my goal? Any idea would be appreciated.
Thanks in advance!
Here are the code:
http://dl.dropbox.com/u/27695108/MariCruz.zip
I hope you can help me.
Thanks!
Upvotes: 1
Views: 1398
Reputation: 69027
You have a couple of problems with your project.
1 First one is that you are using a UITabBarController
, that is why the code you found to hide the root view controller does not work.
makeSplitViewController
, where you are initializing twice your splitViewController
, rootViewController
, and detailViewController
.So, you have to fix point 2, so that you can correctly manage all of those controllers and then you should modify toggleSplitView
so that you take into account the fact that you are using a UITabBarController. For example, replace the first few lines of that method with the following ones:
- (void)toggleSplitView {
NSArray *controllers = _tabBarController.viewControllers;
UIViewController* controller = [controllers objectAtIndex:1];
if (controller.view == splitViewController.view) {
[splitViewController.view removeFromSuperview];
splitViewController.viewControllers = [NSArray arrayWithObjects:rootViewController, rootViewController, nil];
splitViewController.view = detailViewController.view;
} else {
....
As you say, I am no accessing _window
to check if the UISplit is there, because that view is not under _window, rather it is in the tab bar. The other branch of the if
also needs to be rewritten according to the same criteria, but I will leave it for you.
The above code will work only with your second tab (the one corresponding to index 1); indeed, since you are overwriting splitViewController
in makeSplitViewController
, I can only use the element at index 1 in the tab bar without making further changes.
Upvotes: 1