我正在使用 Parse 使用 Swift 开发 iPhone 应用程序。 我使用 Parse 的 PFLoginViewController 创建了一个简单的登录屏幕。当用户执行没有用户名注册等操作时,会出现弹出窗口(UIAlertControllers),但当登录凭据无效时,不会弹出窗口。相反,我只是在控制台中收到错误:
2015-08-23 22:50:10.246 SwifferApp[24429:1614072] [Error]: invalid login parameters (Code: 101, Version: 1.8.1)
我有一个登录失败时的函数,但我无法通过 PFLoginViewController 呈现 UIAlertController
func logInViewController(logInController: PFLogInViewController, didFailToLogInWithError: NSError?){
var invalidCredentials = UIAlertController(title: "Invalid Credentials", message: "Incorrect username or password.", preferredStyle: UIAlertControllerStyle.Alert)
invalidCredentials.addAction(UIAlertAction(title: "Okay", style: .Default, handler: { (action: UIAlertAction!) in
//do nothing
}))
presentViewController(invalidCredentials, animated: true, completion: nil)
}
在“presentViewController”线上我收到错误
2015-08-23 22:50:10.249 SwifferApp[24429:1613783] Warning: Attempt to present <UIAlertController: 0x7c1f1a50> on <SwifferApp.TimelineTableViewController: 0x7c1b7120> whose view is not in the window hierarchy!
如何添加登录错误弹出窗口?
最佳答案
明白了!
我需要做的就是更换
presentViewController(invalidCredentials, animated: true, completion: nil)
与
logInViewController.presentViewController(invalidCredentials, animated: true, completion: nil)
关于ios - 解析登录错误不会弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32173958/