簡體   English   中英

SWIFT:推式搜索會導致模式搜索

[英]SWIFT: Push segue is resulting in a modal segue instead

在我的情節提要中,模態選擇將用戶帶到“登錄”屏幕(從主屏幕)。 然后,我從“注冊”屏幕向下一個屏幕(“創建配置文件”)添加了一個PUSH segue,該屏幕嵌入在導航控制器中(“創建配置文件”屏幕是其中包含“測試”按鈕的屏幕)。

在此處輸入圖片說明

在此處輸入圖片說明

“注冊”屏幕的設置正常。 但是,當用戶輸入其憑據並單擊“注冊”時,確實會將其帶到正確的屏幕,但是使用了模態搜索與推送搜索。 我不知道為什么會這樣。

這是我的注冊視圖控制器代碼。 任何幫助將不勝感激!

import UIKit
import Parse

class SignInViewController: UIViewController {

@IBOutlet weak var usernameField: UITextField!
@IBOutlet weak var passwordField: UITextField!

@IBAction func signInButton(sender: AnyObject) {

    PFUser.logInWithUsernameInBackground(usernameField.text!, password:passwordField.text!) {
        (user: PFUser?, error: NSError?) -> Void in
        if user != nil {

            //self.performSegueWithIdentifier("loginUser", sender: self)

            self.usernameField.text = ""
            self.passwordField.text = ""

        } else {

            if let errorString = error?.userInfo["error"] as? String {

                self.displayAlert("Login Failed", message: errorString)

            }

        }
    }

}

@IBAction func signUpButton(sender: AnyObject) {

    if usernameField.text == "" || passwordField.text == "" {

        self.displayAlert("Missing Field(s)", message: "Username and password are required")

    } else {

        let user = PFUser()
        user.username = usernameField.text
        user.password = passwordField.text

        user.signUpInBackgroundWithBlock {
            (succeded, error) -> Void in

            if let error = error {
                if let errorString = error.userInfo["error"] as? String {

                    self.displayAlert("Sign Up Failed", message: errorString)

                }


            } else {

                self.performSegueWithIdentifier("SignUpToCreate", sender: self)

                self.usernameField.text = ""
                self.passwordField.text = ""

            }
        }
    }
}

//Dismiss the sign in screen
@IBAction func closeButton(sender: AnyObject) {

    self.dismissViewControllerAnimated(true, completion: nil)

}

override func viewDidLoad() {
    super.viewDidLoad()

    //Format the text fields
    textFieldUI()


}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}








//Display alert function
func displayAlert(title: String, message: String) {

    let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
    self.presentViewController(alert, animated: true, completion: nil)

}

//Textfield UI
func textFieldUI() {

    passwordField.leftView = UIView(frame: CGRectMake(0, 0, 8, 0))
    passwordField.leftViewMode = .Always
    usernameField.leftView = UIView(frame: CGRectMake(0, 0, 8, 0))
    usernameField.leftViewMode = .Always

}

}

這是不可能的:

Root --(modal)--> SignUp --(push)--> NavigationController<->Detail

結構應該是這樣的

Root --(modal)--> NavigationController<->Signup --(push)--> Detail

我認為您的設計有誤,因為您不想在注冊控制器中顯示導航欄。 您可以通過在顯示它之前設置視圖控制器navigationBarHidden來防止這種情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM