1

I am using the Parse login controller (default Parse one they offer) to implement a user login/pass for my app. It works fine, I am able to log in, register, and the whole thing. Only thing is that I want to add an alert if the password is wrong, right now it only println("Failed to login...") when the password is wrong, and the user has no idea that their password is wrong. I added an alert, but some reason it isn't appearing. The error message I get is "Warning: Attempt to present on whose view is not in the window hierarchy!"

Here is the alert I added to my code:

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)

}

I think it might be because the parse default login screen I am using that they provided is not on my storyboard, but called from the Parse framework(?). How do I go about adding an alert view?

Thank you!

Josh

4

1 回答 1

1

尝试这个

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

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

于 2015-06-25T21:00:15.320 回答