iOS Swift-无法触发segue
我有下面的代码,当用户注册时会显示一个警告框。在用户与警报框按钮交互(即,让我们走)后,我现在需要触发一个名为someSegue的序列,以便将用户重定向到登录页面 用户单击“警报框”按钮后,不会发生任何事情。我错过了什么?那是自我吗?如果我删除self,它将不工作,xcode会抱怨iOS Swift-无法触发segue,ios,swift,segue,Ios,Swift,Segue,我有下面的代码,当用户注册时会显示一个警告框。在用户与警报框按钮交互(即,让我们走)后,我现在需要触发一个名为someSegue的序列,以便将用户重定向到登录页面 用户单击“警报框”按钮后,不会发生任何事情。我错过了什么?那是自我吗?如果我删除self,它将不工作,xcode会抱怨 user.signUpInBackgroundWithBlock { (succeeded, error) -> Void in
user.signUpInBackgroundWithBlock {
(succeeded, error) -> Void in
if error == nil {
// Hooray! Let them use the app now.
let delay = 4.5 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) {
actInd.stopAnimating()
var alert = UIAlertController(title: "Congratulations!", message: "Your account was successfully created! You will be required to login with your credentials.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Let's Go!", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
self.performSegueWithIdentifier("someSegue", sender: self)
}
} else {
// Show the errorString somewhere and let the user try again.
}
}
如果要在按下警报按钮后执行代码块,则需要在addAction方法的处理程序参数中传递该代码块
alert.addAction(UIAlertAction(title: "Let's Go!", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) in
self.performSegueWithIdentifier("someSegue", sender: self)
}))
尝试在调度\u异步调度\u获取\u主队列,{}内调用PerformsgueWithIdentifier