Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode UIAlertController无法显示UIAlertView_Xcode_Swift_Parsing_Parse Platform - Fatal编程技术网

Xcode UIAlertController无法显示UIAlertView

Xcode UIAlertController无法显示UIAlertView,xcode,swift,parsing,parse-platform,Xcode,Swift,Parsing,Parse Platform,当登录凭据错误时,我想显示一个UIAlertView,但它只是转到下一个视图,不显示UIAlertView? 它表示登录凭据无效,但似乎忽略了错误。我尝试了一个定制的segue,但当按下按钮时,它会自动调用。我没有自我介绍,所以是代码。如果可达性不是问题,只需检查用户是否连接到internet,这不是问题 func login() { if Reachability.isConnectedToNetwork() { activityLoader.alpha =

当登录凭据错误时,我想显示一个
UIAlertView
,但它只是转到下一个视图,不显示
UIAlertView?

它表示登录凭据无效,但似乎忽略了错误。我尝试了一个定制的segue,但当按下按钮时,它会自动调用。我没有自我介绍,所以是代码。如果可达性不是问题,只需检查用户是否连接到internet,这不是问题

func login()
{

    if Reachability.isConnectedToNetwork()
    {
        activityLoader.alpha = 1
        activityLoader.startAnimating()
        let emailText = EmailTextBox.text

        PFUser.logInWithUsernameInBackground(EmailTextBox.text!, password: PasswordTextBox.text!){(user: PFUser?, error: NSError?) -> Void in
            if user != nil
            {
                //Login Successfully
                NSUserDefaults.standardUserDefaults().setObject(emailText, forKey: "UserSaved")
                NSUserDefaults.standardUserDefaults().synchronize()

                self.activityLoader.alpha = 0
                self.activityLoader.stopAnimating()


                let title = "Successfully logged in"
                let message = "Enjoy"
                let okText = "OK"

                let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
                let OKbutton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
                alert.addAction(OKbutton)
                self.presentViewController(alert, animated: true, completion: nil)


            }
            else
            {
                self.activityLoader.alpha = 0
                self.activityLoader.stopAnimating()

                let title = "Please try again"
                let message = "Check your login credentials"
                let okText = "OK"

                let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
                let OKbutton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
                alert.addAction(OKbutton)
                self.presentViewController(alert, animated: true, completion: nil)

            }
        }
    }
    else
    {
        self.activityLoader.alpha = 0
        self.activityLoader.stopAnimating()

        let title = "No Internet Connection"
        let message = "Please ensure you are connected to the Internet"
        let okText = "OK"

        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
        let OKbutton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
        alert.addAction(OKbutton)
        self.presentViewController(alert, animated: true, completion: nil)


    }


}


@IBAction func LogInPressed(sender: AnyObject)
{

    if self.EmailTextBox.text == "" ||  self.PasswordTextBox.text == ""
    {
        let title = "Please try again"
        let message = "Check your login credentials"
        let okText = "OK"

        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
        let OKbutton = UIAlertAction(title: okText, style: UIAlertActionStyle.Cancel, handler: nil)
        alert.addAction(OKbutton)
        self.presentViewController(alert, animated: true, completion: nil)
    }

    else
    {
        login()
    }
}

检查序列图像板文件中是否没有从按钮到下一个视图控制器的序列。

检查序列图像板文件中是否没有从按钮到下一个视图控制器的序列。

“它表示登录凭据无效,但似乎忽略了错误。”它在哪里表示“登录凭据无效”?该字符串不会出现在您的程序中。还有,你所说的“错误”是什么意思?“我没有自我介绍,所以是代码。”这很难理解。你能澄清一下吗?“如果可达性不是问题,只需检查用户是否连接到互联网,这不是问题。”这也很难理解。你也能澄清一下吗?“它说的是无效的登录凭据,但似乎忽略了错误。”它在哪里说的是“无效的登录凭据”?该字符串不会出现在您的程序中。还有,你所说的“错误”是什么意思?“我没有自我介绍,所以是代码。”这很难理解。你能澄清一下吗?“如果可达性不是问题,只需检查用户是否连接到互联网,这不是问题。”这也很难理解。你也能澄清一下吗?