你好,
这是我的代码:
@IBAction func logOutAction(sender: AnyObject) {
try! FIRAuth.auth()!.signOut()
let alertController = UIAlertController(title: "Sure?", message: "Are you sure you want to log out?", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "Yes", style: .Default, handler: nil)
alertController.addAction(defaultAction)
let defaultAction2 = UIAlertAction(title: "No", style: .Cancel, handler: nil)
alertController.addAction(defaultAction2)
self.presentViewController(alertController, animated: true, completion: nil)
let VC = self.storyboard?.instantiateViewControllerWithIdentifier("loginscreen") as! ViewController //The file that controls the view
self.presentViewController(VC, animated: true, completion: nil)
}
如您所见,我想在按下注销按钮时注销用户。当用户单击注销时,UIalert 弹出窗口询问他们是否确定要注销,但是当我单击“确定”时,它不会切换回登录界面 ViewController。
谁能帮帮我?
最佳答案
如果最后两行表示您要呈现的 View ,那么您必须在"is"按钮操作的处理程序中执行此代码:
let defaultAction = UIAlertAction(title: "Yes", style: .Default, handler: { _ in
let VC = self.storyboard?.instantiateViewControllerWithIdentifier("loginscreen") as! ViewController //The file that controls the view
self.presentViewController(VC, animated: true, completion: nil)
})
alertController.addAction(defaultAction)
关于ios - 单击警报按钮不起作用时更改 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38658279/