找到你要的答案

Q:Why detailViewController is not in UISplitViewController.viewControllers anymore?

Q:为什么detailviewcontroller不uisplitviewcontroller.viewcontrollers了吗?

I use UISplitViewController to build my app. Both the master view controller and detail view controller are UINavigationControllers, as illustrated in the Figure. Storyboard

In the viewDidLoad() functions of both master vc and detail vc, the following code is inserted:

    println(self.splitViewController!.viewControllers.count)
    for vc in self.splitViewController!.viewControllers {
        println(vc.hashValue)
    }

The result is:

master vc.viewDidLoad()

2
140692681984032
140692680836304

detaiVC.viewDidLoad()

1
140692681984032

It turns out that in detaiVC.viewDidLoad(), detailVC is not in splitViewController.viewControllers any more. Why?

I use UISplitViewController to build my app. Both the master view controller and detail view controller are UINavigationControllers, as illustrated in the Figure. Storyboard

在viewdidload()功能的详细掌握VC和VC,插入下面的代码:

    println(self.splitViewController!.viewControllers.count)
    for vc in self.splitViewController!.viewControllers {
        println(vc.hashValue)
    }

其结果是:

viewdidload()掌握VC++。

2
140692681984032
140692680836304

detaivc。viewdidload()

1
140692681984032

It turns out that in detaivc。viewdidload(), detailVC is not in splitViewController.viewControllers any more. Why?

answer1: 回答1:

When running your app in a compact width, the splitviewcontroller will be compacted. ie the var viewControllers property only contains 1 view controller.

From the documentation:

When the split view interface is expanded, this property contains two view controllers; when it is collapsed, this property contains only one view controller.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/#//apple_ref/occ/instp/UISplitViewController/viewControllers

在一个紧凑的宽度运行你的应用程序时,该splitviewcontroller将压实。即无功viewcontrollers属性只包含1个视图控制器。

从文件:

When the split view interface is expanded, this property contains two view controllers; when it is collapsed, this property contains only one view controller.

http:/ /开发商。苹果。COM /图书馆/ iOS /文件/ UIKit /参考/ uisplitviewcontroller_class / # / / / / / apple_ref OCC instp UISplitViewController / viewcontrollers

ios  swift  uinavigationcontroller  uisplitviewcontroller