gpt4 book ai didi

ios - 成功登录时解析切换 View Controller

转载 作者:行者123 更新时间:2023-11-28 09:00:56 27 4
gpt4 key购买 nike

用户成功登录后,我需要将 View Controller 切换到我的应用程序的时间轴部分,这也将是一个底部有 5 个不同选项卡的选项卡栏 View Controller 。这是我到目前为止的代码,它可以工作并连接到我设置的解析数据库。 导入 UIKit 导入解析

class LoginViewController: UIViewController {

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

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func loginTapped(sender: AnyObject) {

let username = usernameField.text
let password = passwordField.text

PFUser.logInWithUsernameInBackground(username, password:password) {
(user: PFUser?, error: NSError?) -> Void in
if user != nil {
println("Success")
} else {
var loginError:UIAlertView = UIAlertView(title: "Invalid Login", message: "I did not recognize your credentials. Try again?", delegate: self, cancelButtonTitle: "Dismiss")
loginError.show()
}
}
}

@IBAction func closeTapped(sender: AnyObject) {
dismissViewControllerAnimated(true, completion: nil)
}
}

在 println("sucessful") 行中,我需要切换到他们的时间轴主页(标签栏 View Controller ),而不是打印出成功的登录。

最佳答案

如果登录成功,使用 segue 转换到新的 View Controller :

if user != nil {
self.performSegueWithIdentifier("successfulLoginPage", sender: self)

关于ios - 成功登录时解析切换 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32040811/

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