我正在开发一个带有单个按钮的 ViewController(登录应用程序),当我按下此按钮时,我希望我的 UISplitView 如下所示:
- (IBAction)loadSplitViewController:(id)sender {
[self showSplitViewController];
}
为创建我的 splitViewController 而开发的代码是这样的:
-(void)showSplitViewController{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle: nil];
LeftViewController *leftViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"LeftViewController"];
RightViewController *rightViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"RightViewController"];
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftViewController];
UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:rightViewController];
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:leftNavController, rightNavController, nil];
leftViewController.delegate = rightViewController;
splitViewController.delegate = rightViewController;
[self presentViewController:splitViewController animated:YES completion:^{}];
}
问题是......如果我用于显示我的 splitViewController 这一行:
[self presentViewController:splitViewController animated:YES completion:^{}];
给我一个错误
我也试过
[self.view addSubview:splitViewController.view];
但是这样我的 splitViewController 永远不会旋转,并且委托也不能正常工作......而且我不希望我的 splitViewController 成为我的 viewController 的子视图,我希望它看起来更像一个独立的 modalView
任何帮助我都会感激
提前致谢