gpt4 book ai didi

ios - 为什么程序在登录时不执行segue?

转载 作者:行者123 更新时间:2023-11-30 13:58:03 25 4
gpt4 key购买 nike

我有一个登录屏幕,如果单击登录按钮时凭据正确,则将执行 segue。 Segue 具有正确的标识符,并且用户已登录,因为我通过 currentUser 传递数据,并且它显示在控制台中,指示用户已登录,但 Segue 未执行。为什么?下面是我的登录代码。

 @IBAction func loginAction(sender: AnyObject) {

let username = self.usernameField.text
let password = self.passwordField.text


if(username!.utf16.count) < 4 || (password!.utf16.count < 5){

let alert = UIAlertView(title: "Invalid", message: "Username must be greater then 4 and Password must be greater then 5", delegate: self, cancelButtonTitle: "OK")
alert.show()

}else{

self.actInd.startAnimating()

PFUser.logInWithUsernameInBackground(username!, password: password!, block: { (user, error) -> Void in

self.actInd.stopAnimating()

if ((user) != nil) {

var alert = UIAlertView(title: "Success", message: "Logged In", delegate: self, cancelButtonTitle: "OK")
alert.show()

self.performSegueWithIdentifier("login", sender: self)

}else {

let alert = UIAlertView(title: "Error", message: "\(error)", delegate: self, cancelButtonTitle: "OK")
alert.show()

}



})

}


}

最佳答案

您正在后台线程上调用performSegueWithIdentifier。尝试用

包裹它
dispatch_async(dispatch_get_main_queue(),{



})

关于ios - 为什么程序在登录时不执行segue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33351583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com