當有人對警報操作說好時,我想導航回到根視圖控制器。但警報操作不允許訪問自我。如何從Swift中的UIAlertAction訪問自我?
什麼是圍繞工作AlertAction來獲取當前導航控制器,
這裏是代碼,
func buttonAction(sender:UIButton!)
{
let alertController = UIAlertController(title: "IQ", message:"Thank you for your feedback!", preferredStyle: .Alert)
alertController.addAction(okAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
var okAction = UIAlertAction(title: "Menu", style:UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
self.navigationController?.popToRootViewControllerAnimated(true) //error
}