gpt4 book ai didi

ios - 解析中的 AlertViewController

转载 作者:行者123 更新时间:2023-11-28 07:04:34 26 4
gpt4 key购买 nike

我正在使用 Parse 登录 Controller (他们提供的默认 Parse Controller )为我的应用程序实现用户登录/通行证。它工作正常,我可以登录、注册和完成所有操作。唯一的问题是,如果密码错误,我想添加一个警报,现在它只在密码错误时打印(“登录失败...”),而用户不知道他们的密码是错误的。我添加了一个警报,但由于某种原因它没有出现。我收到的错误消息是“警告:尝试呈现其 View 不在窗口层次结构中!”

这是我添加到代码中的警报:

func logInViewController(logInController: PFLogInViewController!, didFailToLogInWithError error: NSError!) {
println("Failed to login...")
let alertView = UIAlertController(title: "Failed to login...", message: "Incorrect password or username.", preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
presentViewController(alertView, animated: true, completion: nil)

}

我认为这可能是因为他们提供的我正在使用的解析默认登录屏幕不在我的 Storyboard上,而是从解析框架调用的(?)。如何添加警报 View ?

谢谢!

乔希

最佳答案

试试这个

logInController.presentViewController(alertView, animated: true, completion: nil)

我认为当您使用无效凭据登录时,parse 会显示一个警报,因此这可能会显示第二次 - 在警报被解除之后。

关于ios - 解析中的 AlertViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31059873/

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