在我更新到Xcode 7之后,我得到了这个错误“类型UIViewController
的值没有成员topViewController”。还有其他人遇到过这个错误吗?topViewController
不再是UIViewController
的一部分了吗?
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)
}
2条答案
按热度按时间nfeuvbwi1#
你必须使它显式化,这样它就知道你试图从Swift 2中的
UINavigationController
获取topViewController
:wz8daaqr2#
用法