Swift 4.0中没有通过Segue调用的函数

时间:2018-02-07 03:36:34

标签: ios swift function

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

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

问题在于,当我按下应用程序中的注销按钮时,永远不会调用实际的注销功能。我相信它的工作原理是因为它会使主用户注册屏幕闪烁一秒钟(按照segue),但该代码永远不会被执行。它只是回到主用户表视图。我在代码中添加了print语句(用于控制台)和断点,但它永远不会那么远。这是下面的代码。它位于UserTableViewController.swift文件中。

导入UIKit import Parse

类UserTableViewController:UITableViewController {

//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")

}

提前感谢您的帮助。很抱歉先前添加了图片。

麦克

2 个答案:

答案 0 :(得分:0)

您的main.storyboard图标为灰色,因为您需要保存该文件。

答案 1 :(得分:0)

您需要按 Command + S 保存灰色文件,然后更改将反映到最新运行的应用程序。