在继续第二个 VC 时得到错误堆栈未更新
while pushing on second VC getting error stack not updated
我正在创建一个 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()
很快你就会在导航控制器上执行推送。
尝试在代码行上方添加注释并尝试登录。
我正在创建一个 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()
很快你就会在导航控制器上执行推送。
尝试在代码行上方添加注释并尝试登录。