我正在使用SWRevealViewController
当我点击BackButton时出现此错误
fatal error: unexpectedly found nil while unwrapping an Optional value
我的代码
let nesne:SWRevealViewController = self.revealViewController()//the error here
let mainStroyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let desController = mainStroyBoard.instantiateViewController(withIdentifier: "MessageViewController") as! MessageViewController
let newFrontViewController = UINavigationController.init(rootViewController:desController)
nesne.pushFrontViewController(newFrontViewController, animated: true)
答案 0 :(得分:0)
溶液
let sw = storyboard?.instantiateViewController(withIdentifier: "SWRevealViewController") as! SWRevealViewController
self.view.window?.rootViewController = sw
let mainStroyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let desController = mainStroyBoard.instantiateViewController(withIdentifier: "MessageViewController") as! MessageViewController
let newFrontViewController = UINavigationController.init(rootViewController:desController)
sw.pushFrontViewController(newFrontViewController, animated: true)