解析退出功能

时间:2015-07-05 01:51:14

标签: ios swift parse-platform

我正在尝试一个简单的退出功能,在用户退出后,视图会返回到我的登录/注册视图。我尝试过使用这两种方法,但应用程序每次都会崩溃。

第一种方法:

@IBAction func signPressed(sender: AnyObject) {

    PFUser.logOut()

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("ViewController") as! UIViewController
    presentViewController(vc, animated: true, completion: nil)
}

第二种方法:

我创建了以下功能:

func loginSetup() {

        if (PFUser.currentUser() == nil) {

            let vc = ViewController()
            self.presentViewController(vc, animated: true, completion: nil)

          }
}

然后将其添加到我的退出功能:

@IBAction func signPressed(sender: AnyObject) {

    PFUser.logOut()

    self.loginSetup()
}

两人都崩溃并给了我一个app delegate错误..这是什么问题?

这是给出错误的屏幕截图:

https://40.media.tumblr.com/1f044ecbdd5059836b0a360d16af9846/tumblr_nqzsobll0o1tupbydo1_1280.png

1 个答案:

答案 0 :(得分:0)

提供您已将根VC设置为登录/注册屏幕。

JacksonJsonProvider

然后你可以在UIButton IBAction中调用这个函数,但我在我的UINavigationBar上调用它,就像这样,

    func didTapSignOut(sender: AnyObject)
{
    PFUser.logOut()

    self.navigationController?.popToRootViewControllerAnimated(true)
}