我有一个UINavigationController
呈现了几个UIViewControllers
。然后我想切换到UISplitviewController
。
所以我在app-Delegate中实现了一个方法useSplitViewController
,我从上一个UIViewController
调用了该方法。它显示SplitView
,但我无法旋转设备。我的ViewController
中的SplitviewController
s不会获得旋转事件。我的错误是什么?如何解决?
-(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;
}
答案 0 :(得分:1)
您需要设置窗口的根视图控制器:
替换
[window addSubview:self.splitViewController.view];
用,
[window setRootViewController:self.splitViewController];