gpt4 book ai didi

ios - SWIFT:推送 segue 导致模态 segue

转载 作者:搜寻专家 更新时间:2023-11-01 06:21:15 28 4
gpt4 key购买 nike

在我的 Storyboard中,模态转场将用户带到登录屏幕(从主屏幕)。然后,我从注册屏幕添加了一个 PUSH segue 到下一个屏幕(创建配置文件),该屏幕嵌入在导航 Controller 中(创建配置文件屏幕是包含“测试”按钮的屏幕)。

enter image description here

enter image description here

注册屏幕的转接工作正常。然而,当用户输入他们的凭据并单击“注册”时,它确实会将他们带到正确的屏幕,但使用模式转场与推送转场。我不知道为什么会这样。

这是我的注册 View Controller 代码。任何帮助将不胜感激!

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

我认为您的设计有误,因为您不想在注册 Controller 中显示导航栏。您可以通过在显示之前设置 View Controller navigationBarHidden 来防止这种情况。

关于ios - SWIFT:推送 segue 导致模态 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33709636/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com