从 UINavigationController 切换到 UISplitviewController
我有一个 UINavigationController,它提供了几个 UIViewController。然后我想切换到 UISplitviewController 。
因此,我在我的应用程序委托中实现了一个方法 useSplitViewController
,我从最后一个 UIViewController
调用该方法。它显示了 SplitView
,但我无法旋转我的设备。我的 SplitviewController
内的 ViewController
没有获得旋转事件。我的错误是什么?我该如何解决?
-(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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置窗口的根视图控制器:
替换
为,
You need to set the root view controller of the window:
replace
with,