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
Ios 解析签出函数_Ios_Swift_Parse Platform - Fatal编程技术网

Ios 解析签出函数

Ios 解析签出函数,ios,swift,parse-platform,Ios,Swift,Parse Platform,我正在尝试一个简单的注销函数,在用户注销后视图返回到我的登录/注册视图。我尝试过使用这两种方法,但每次应用程序都会崩溃 第一种方法: @IBAction func signPressed(sender: AnyObject) { PFUser.logOut() let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWit

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

第一种方法:

@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()
}
然后将其添加到我的注销功能中:

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()
}
两者都崩溃了,并给了我一个应用程序委托错误。。这里有什么问题

以下是给出的错误截图:


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

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

    self.navigationController?.popToRootViewControllerAnimated(true)
}
然后你可以在UIButton iAction中调用这个函数,但我在UINavigationBar上调用它,就像这样

        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Sign Out", style: .Plain, target: self, action: "didTapSignOut:")

那么错误信息是什么?您的信息不足以让我们帮助您。这根本没有帮助,控制台上是否打印了任何内容?不,控制台上没有任何内容,结果表明该方法调用的是视图控制器情节提要标识,而不是视图本身的名称。目标视图标识为空现在按钮根本不起作用,就像没有插座的按钮一样确保按钮的插座选项卡中所有插座都已连接,并确保在代码中UIButton操作旁边有一个实心灰点,因为您可能需要重新连接它。我想不出这个功能不起作用的任何理由,所以请检查您的please Action Outlets。这就是我无法解决的问题,但我在视图中的特定位置有我的注销按钮,非导航栏确保您的按钮是通过iAction而非IBOutlet连接的,并且在Action或Outlet调用旁边有一个填充的灰点。我在上面的评论中并没有提到导航栏。