I use UISplitViewController to build my app. Both the master view controller and detail view controller are UINavigationControllers, as illustrated in the Figure.
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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.