當用戶在alertView中按回車鍵時,我試圖回到viewcontroller,它向我顯示錯誤(libC++ abi.dylib:以NSException類型的未捕獲異常終止)如何在alertview中回到viewcontroller
@IBAction func roundButton(sender: AnyObject) {
//add alert
alertController = UIAlertController(title: "Return Home", message: "Are you sure???", preferredStyle: .Alert)
let alertAction1 = UIAlertAction(title: "Cancel", style: .Default) { (action) in
}
let alertAction2 = UIAlertAction(title: "Go Home", style: .Destructive) { (action) in
let nv = self.storyboard!.instantiateViewControllerWithIdentifier("storyboardidentifier") as! ViewController
self.presentViewController(nv, animated:true, completion:nil)
}
alertController?.addAction(alertAction2)
alertController?.addAction(alertAction1)
self.presentViewController(alertController!, animated: true, completion: nil)
//end alert
}
你能告訴我異常消息?在堆棧跟蹤之前,通常會有一條消息跟在異常之後。 – Sweeper