gpt4 book ai didi

ios - 在插入第二个 VC 时出现错误堆栈未更新

转载 作者:行者123 更新时间:2023-11-29 05:29:35 25 4
gpt4 key购买 nike

我正在创建一个Swift应用程序,通过这个应用程序,用户可以使用他们的电子邮件登录,因此我创建了网络服务,用户可以成功登录,但登录后,当我收到成功响应时,我是重定向回应用程序的主屏幕,但 pushViewController 不起作用,我收到以下错误

pushViewController:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated.

下面是我使用 api 集成和重定向代码登录的代码

 let params = ["email":txtEmail.text!,"password":txtPassword.text! ,"device_type":"iOS" , "device_token": deviceid]
print(params)
self.viewMainSpinner.isHidden = false
self.viewInnerSpinner.startAnimating()

Alamofire.request(login, method: .post, parameters: params).responseJSON(completionHandler: {(response) in
print(response.result)
switch response.result{

case.success(let value):
let json = JSON(value)

let success = json["success"].stringValue

if success == "1"{

let message = json["message"].stringValue

let data = json["data"]
let accesstkn = data["access_token"].stringValue
let userid = data["user_id"].stringValue
let firstName = data["first_name"].stringValue


let preferences = UserDefaults.standard

let uid = "u_id"
let acctkn = "acc_tkn"
let f_name = "first_name"

let u_id = userid
let acc_tkn = accesstkn
let firName = firstName


preferences.set(u_id, forKey: uid)
preferences.set(acc_tkn, forKey: acctkn)
preferences.set(firName, forKey: f_name)


Loaf(message, state: .success, sender: self).show()

let storyboard = UIStoryboard(name: "Functional", bundle: nil)
let VC = storyboard.instantiateViewController(withIdentifier: "CustomTabBarViewController") as! CustomTabBarViewController
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
self.navigationController?.pushViewController(VC, animated: true)
}else{
let message = json["message"].stringValue
Loaf(message, state: .error, sender: self).show()
}
case.failure(let error):
Loaf(error.localizedDescription, state: .error, sender: self).show()
}
self.viewMainSpinner.isHidden = true
self.viewInnerSpinner.stopAnimating()
})

请检查这里是我的登录代码,登录后我无法在主屏幕上重定向

请告诉我为什么会发生这种情况?

最佳答案

看起来 show() 方法实现正在以下代码行中执行导航相关操作:

Loaf(message, state: .success, sender: self).show()

之后很快您就可以在导航 Controller 上执行推送。

尝试注释上面的代码行并尝试登录。

关于ios - 在插入第二个 VC 时出现错误堆栈未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57781952/

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