gpt4 book ai didi

xcode - UIAlertViewController 在实际呈现之前显示出一点延迟

转载 作者:行者123 更新时间:2023-11-30 10:13:49 28 4
gpt4 key购买 nike

我有一个 UIAlertViewController 需要一段时间才能呈现,一段时间后大约需要一秒钟......代码如下。

PFUser.logInWithUsernameInBackground(usernameTextField.text!, password:passwordTextField.text!) {
(user: PFUser?, error: NSError?) in
if user != nil{

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

} else {

let alert = UIAlertController(title: "Error", message: "Entered User Creditinials Are Incorrect. Please Try Again.", preferredStyle: UIAlertControllerStyle.Alert)

let action = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) in

})

alert.addAction(action)

self.presentViewController(alert, animated: true, completion: nil)
}

}

提前谢谢您:)

最佳答案

我稍微改变了你的代码,现在 UIAlertController 立即弹出。我使用了 Parse.com 错误代码;

PFUser.logInWithUsernameInBackground(usernameTextField.text!, password:passwordTextField.text!) {
(user: PFUser?, error: NSError?) -> Void in
if user != nil {
self.performSegueWithIdentifier("toMainView", sender: self)
} else {
let ErrorCode = error!.code
switch ErrorCode {
case 101:
let alert = UIAlertController(title: "Error", message: "Entered User Creditinials Are Incorrect. Please Try Again.", preferredStyle: UIAlertControllerStyle.Alert)
let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:{ (action: UIAlertAction!) in })
alert.addAction(action)
self.presentViewController(alert, animated: true, completion: nil)
break
default:
println(ErrorCode)
break
}

}
}

您可以看到解析错误代码here .

关于xcode - UIAlertViewController 在实际呈现之前显示出一点延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31369242/

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