繁体   English   中英

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

[英]Function Not Being Called Through Segue in Swift 4.0

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

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

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

导入 UIKit 导入解析

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

}

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

麦克风

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM