Multiple DetailViewControllers using a UISplitViewController
当前,我有一个带有MasterViewController和DetailViewController的SplitViewController。我想知道是否有办法拥有更多的DetailViewControllers。现在,我在左侧的tableView中有一个项目列表,如果单击它们,它们将进入全屏视图。当我单击时,如何保持它显示在splitview右侧的面板内?因此,参考此图像-如何使我的视图在详细信息部分显示为黄色?现在,当我单击等效的"黄色"时-黄色全屏显示,而不是详细信息。 http://2uagoo1zzsoo4bcz3347bs2y.wpengine.netdna-cdn.com/wp-content/uploads/2012/08/Image003.png
其他信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if indexPath.row == 0 { let storyboard: UIStoryboard = UIStoryboard(name:"Main", bundle: nil) let vc: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("newViewController") as! UINavigationController self.presentViewController (vc, animated: true, completion: nil) } else if indexPath.row == 3 { let storyboardTwo: UIStoryboard = UIStoryboard(name:"Main", bundle: nil) let vcTwo: UINavigationController = storyboardTwo.instantiateViewControllerWithIdentifier("newViewController4") as! UINavigationController self.presentViewController(vcTwo, animated: true, completion: nil) } |
我相信您需要使用show showDetailViewController方法:
将指定的视图控制器作为拆分视图界面的辅助视图控制器。
1 2 | func showDetailViewController(_ vc: UIViewController, sender sender: AnyObject?) |
因此,在您的情况下,它会像这样使用。在didSelectRowAtIndexPath函数中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | { let vc:UIViewController if indexPath.row == 0 { let storyboard: UIStoryboard = UIStoryboard(name:"Main", bundle: nil) vc: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("newViewController") as! UINavigationController } else if indexPath.row == 3 { let storyboardTwo: UIStoryboard = UIStoryboard(name:"Main", bundle: nil) vc: UINavigationController = storyboardTwo.instantiateViewControllerWithIdentifier("newViewController4") as! UINavigationController }else { // handle this case vc = ... } // Grab the Split View Controller let splitVC = // get Split View Controller splitVC.showDetailViewController(vc,sender:nil) } |