使用 UISplitViewController 的多个 DetailViewController

Multiple DetailViewControllers using a UISplitViewController

目前,我有一个带有 MasterViewController 和一个 DetailViewController 的 SplitViewController。我想知道是否有办法拥有更多 DetailViewController。现在我在左侧的 tableView 中有一个项目列表,如果您单击它们,它们将进入全屏视图。我怎样才能让它在单击时显示在 splitview 右侧的面板内?那么参考这张图片——我怎样才能让我的视图在细节部分像黄色一样显示?现在,当我点击 "yellow" 的等价物时 - 黄色显示为全屏,而不是细节。 http://2uagoo1zzsoo4bcz3347bs2y.wpengine.netdna-cdn.com/wp-content/uploads/2012/08/Image003.png

额外信息:

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 方法:

将指定的视图控制器呈现为拆分视图界面的辅助视图控制器。

func showDetailViewController(_ vc: UIViewController,
                   sender sender: AnyObject?)

所以在你的情况下它会更像这样使用。在 didSelectRowAtIndexPath 函数中:

{
    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)
}