4
更新到Xcode 7後,出現此錯誤「類型爲UIViewController
的值沒有成員topViewController。其他人遇到這個? topViewController
不再是UIViewController
的一部分嗎?Xcode 7更新後類型UIViewController的值沒有成員topViewController
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)
}
燁,我最終計算出來。我把這個:如果讓split = self.splitViewController讓controllers = split.viewControllers self.detailViewController = (controllers [controllers.count-1] as!UINavigationController).topViewController as? DetailViewController } –
'as? DetailViewController'的鑄造非常重要。謝謝。 – tymac
感謝tymac指出這一點;) – Marin