在Swift 4.0中未通过SEGUE调用功能



我已经开始学习Swift 4和iOS应用程序开发。

我已经设置了一个基本应用程序,该应用程序允许用户注册并将自己添加到用户表或登录并显示已经注册的用户。我已经在主故事板上创建了一个条按钮项目(注销(,并将该按钮连接到主用户屏幕。我还创建了一个用户表视图控制器,该功能可以注销用户。以下是代码,主说板以及SEGUE和按钮定义的图像。

问题是,当我按应用程序中的注销按钮时,实际的注销函数从未调用。我相信它有效,因为它可以闪烁一秒钟的主要用户注册屏幕(根据SEGUE(,但是该代码从未执行。它只是返回到主用户表视图。我在代码中添加了打印语句(用于控制台(和断点,但是它永远不会走那么远。这是下面的代码。它在usertableViewController.swift文件中。

导入Uikit导入分析

类UsertableViewController:uitaiteViewController {

//function to control what happens when the user presses the logout button

@IBAction func logoutUser(_ sender: Any) {
    // log the user out; make sure you import Parse into the view controller so you can access the PFUser functions
    print ("getting ready to logout user")
    PFUser.logOut()
    print ("logged out user from parse")
    // perform the segue to the main login screen; don't need self. before the performSegue because we want the action to happen in the main view controller
    performSegue(withIdentifier: "logoutSegue", sender: self)
    print("You should see the main screen now")
}

事先感谢您的帮助。抱歉,添加了前面的图片。

Mike

您的主板图标是灰色的,因为您需要保存该文件。

您需要通过按命令 s 来保存灰色文件,然后在更改后将反映到最新的运行应用程序中。

最新更新