簡體   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