我有包含此功能prepareForSegue表視圖:的TableView和和按鈕(崩潰)
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController
let myindexpath = self.MainPageTableView.indexPathForSelectedRow
let titleString = self.CategoryTitle.object(at: ((myindexpath as NSIndexPath?)?.row)!) as? String
upcoming.titlestring = titleString
self.MainPageTableView.deselectRow(at: myindexpath!, animated: true)
}
從6個拿到冠軍,並將它們保存到nvigational欄標題下一個視圖。
在這個包含準備segue功能的視圖中,導航欄中有一個按鈕可以移動到另一個(第三個)視圖控制器!
每當我點擊該按鈕,在這條線的應用程序崩潰:
let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController
我知道錯誤的原因,但我怎麼能解決呢?
您知道錯誤的原因是什麼?日誌中提到你的崩潰情況? – Santosh
即將到來的應該是CategoryDeviceViewController,但當點擊按鈕時,它打開第三個視圖控制器 – Mariah
您是否在這個'segue'的故事板中正確設置了'destination' viewController? – Santosh