Reputation: 7413
I have a UINavigationController
presenting a couple of UIViewControllers
. Then I want to switch to a UISplitviewController
.
So I implemented a method useSplitViewController
in my app-Delegate that I call from my last UIViewController
. It shows the SplitView
, but I can't rotate my device. The ViewController
s inside my SplitviewController
don't get the rotation-event. What is my mistake and how can I solve it?
-(void)useSplitViewController{
[self.menuViewController.view removeFromSuperview];
self.menuViewController = nil;
self.navcon = nil;
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewController=[[[FirstDetailViewController alloc]init] autorelease];
UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];
self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
self.splitViewController.delegate=self.detailViewController;
// Add the split view controller's view to the window and display.
[window addSubview:self.splitViewController.view];
[window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.navcon = [[UINavigationController alloc] init];
self.menuViewController = [[MenuViewController alloc] init];
self.menuViewController.appDelegate = self;
[self.navcon pushViewController:self.menuViewController animated:NO];
[window addSubview:self.menuViewController.view];
[window makeKeyAndVisible];
//[self useSplitViewController];
return YES;
}
Upvotes: 2
Views: 1773
Reputation: 5156
You need to set the root view controller of the window:
replace
[window addSubview:self.splitViewController.view];
with,
[window setRootViewController:self.splitViewController];
Upvotes: 1