在我更新到 Xcode 7后,我收到此错误“类型UIViewController的值没有成员topViewController.”其他人遇到这个? topViewController不再是UIViewController的一部分吗? override func viewDidLoad() { super.viewDidLo
override func viewDidLoad() { super.viewDidLoad() self.navigationItem.leftBarButtonItem = self.editButtonItem() let addButton = UIBarButtonItem(barButtonSystemItem: .Search, target: self, action: "addButtonPressed:") self.navigationItem.rightBarButtonItem = addButton if let split = self.splitViewController { let controllers = split.viewControllers self.detailViewController = controllers[controllers.count-1].topViewController as? ### Error heres DetailViewController } model = Model(delegate: self) // create the Model model.synchronize() // tell model to sync its data self.navigationController?.toolbarHidden = false; self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"Home", style:.Plain, target:nil, action:nil) }你必须明确它,以便它知道你正在尝试从Swift 2中的UINavigationController获取topViewController:
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController