我发送参数,信息,对象,一切正常,使用MasterViewController中的segues
但是我的一些UIViewControllers通过使用Segues与其他UIViewControllers交互,因此,为了使它们正常工作,我需要将它们嵌入到UINavigationController中
我的问题是:
当正在执行segue时,如何将UINavigationController添加到我的segue.destinationViewController:
>从masterViewController传递我的参数
>允许我的UIViewControllers通过使用Segues与其他ViewControllers交互
我想在一个解决方案中:
– 通过在MasterViewController中创建自定义委托或协议来解决参数问题
-UINavigationControllers问题是通过在其中嵌入我的UIViewControllers在故事板中以设计模式添加它们
但我需要设置我的destinationViewController UISplitViewController的委托,用于显示以纵向模式显示MasterViewController的按钮…
如果我在prepareForSegue方法中设置它,让UINavigationControllers保持我的ViewControllers,我将把UISplitViewController的委托设置为UINavigationController而不是
在此先感谢您的帮助
编辑:这是我找到解决它的方式:
首先我给一个按钮分配了一个IBAction,如果我的设备不是iPad,它会做正常的…
- (IBAction)openExecutives:(id)sender { if ([[[UIDevice currentDevice]model] hasPrefix:@"iPad"]) { UsersListVC *rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"UsersListVC"]; [self showSplitViewController:rightViewController]; } else [self performSegueWithIdentifier:@"viewSceneExecutives" sender:self]; }
-(void)showSplitViewController:(id)rightViewController{ UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"iPad2" bundle: nil]; UINavigationController *leftNavController; UINavigationController *rightNavController; MainMenuVC *leftViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainMenuVC"]; leftNavController = [[UINavigationController alloc] initWithRootViewController:leftViewController]; rightNavController = [[UINavigationController alloc] initWithRootViewController:rightViewController]; leftNavController.toolbarHidden = FALSE; rightNavController.toolbarHidden = FALSE; UISplitViewController *splitViewController = [[UISplitViewController alloc] init]; splitViewController.viewControllers = [NSArray arrayWithObjects:leftNavController,rightNavController,nil]; splitViewController.delegate = rightViewController; self.view.window.rootViewController = splitViewController; }
我所做的就是通过创建一个需要参数的函数(UIViewController)从重新开始重绘splitViewController
解决方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UINavigationController *dest = (UINavigationController *)segue.destinationViewController; self.detailViewController = (DetailViewController *)dest.topViewController; self.splitViewController.delegate = self.detailController; }