ios - 解析登录错误不会弹出

标签 ios swift parse-platform

我正在使用 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/

相关文章:

ios - 动态 ScrollView Swift

c - Swift 使用 c 结构

java - 如何使用 jBcrypt 检查 bcrypt 密码? (将存储从 Parse.com 移至 Firebase)

ios - SwiftUI Picker状态检索索引位置而不是标签

ios - Sprite 套件 | swift 3 |关卡编辑器——从关卡编辑器中引用 SKSpritenodes 的用户数据

ios - 有什么方法可以从 Apple Watch 访问心率传感器吗?

Swift iOS TextView 居中并右对齐某些文本

PHP 命名空间和包含

arrays - 如何按日期对 PFObject 数组进行分组

iphone - 跨 iOS 平台的视频规范