每次显示分割视图控制器时,我都会在控制台中出现此错误。我无法找到具体的解决方案吗?指导?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.makeKeyAndVisible()
let splitViewController = UISplitViewController()
let masterViewController = TabBarMaster(collectionViewLayout: UICollectionViewFlowLayout())
let detailViewController = UINavigationController()
splitViewController.maximumPrimaryColumnWidth = 80
splitViewController.preferredDisplayMode = .AllVisible
splitViewController.delegate = self
splitViewController.viewControllers = [masterViewController, detailViewController]
window?.rootViewController = splitViewController
return true
}
答案 0 :(得分:9)
在设置splitViewController的任何其他属性之前设置splitViewController viewControllers数组:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.makeKeyAndVisible()
let splitViewController = UISplitViewController()
let masterViewController = TabBarMaster(collectionViewLayout: UICollectionViewFlowLayout())
let detailViewController = UINavigationController()
splitViewController.viewControllers = [masterViewController, detailViewController] // move it here
splitViewController.maximumPrimaryColumnWidth = 80
splitViewController.preferredDisplayMode = .AllVisible
splitViewController.delegate = self
window?.rootViewController = splitViewController
return true
}