gpt4 book ai didi

ios - 从 swift 3 中的标签栏移动时如何重新加载页面?

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

运行应用程序后,我当时在选项卡栏中单击了购物车,购物车中没有添加任何商品,因此显示您的购物车是空的,但在购物车中添加商品后,我还单击了选项卡栏上的购物车图标它像以前一样显示并且购物车页面没有重新加载任何人都可以帮我解决这个问题吗?

我在我的主视图 Controller 中使用了这段代码

func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let tabBarIndex = tabBarController.selectedIndex
if tabBarIndex == 1 {
let navController = self.tabBarController?.viewControllers![1] as! UINavigationController
let secondViewController = navController.viewControllers[0] as! AddToCartViewController
secondViewController.firstTimeTableSkip = true
self.tabBarController?.selectedIndex = 1
}
}

在我的购物车 View Controller 中我使用了这段代码

override func viewWillAppear(_ animated: Bool) {
if firstLoginCheck == true {
checkOutButton.isHidden = false
checkOutButton.layer.cornerRadius = 5
if conditonCheck == true || conditonCheck == nil{
checkOutButton.isHidden = true
checkOutButton.layer.cornerRadius = 5
tableDetails.isHidden = true
emptyView.isHidden = true
tableDetails.separatorInset = UIEdgeInsets.zero
loginCheck = UserDefaults.standard.integer(forKey: "CustomerLogin")
activityIndicator.startAnimating()
emptyView.isHidden = true
if loginCheck == 1 {
let token = UserDefaults.standard.value(forKey: "CustomerLoginToken")
self.customerKeyToken = token!
print(self.customerKeyToken!)
if itemCode != nil {
self.customerAddToCartItemsDownloadJsonWithURl(cartApi: customerAddtoCartApi)
customerCartItemsDownloadJsonWithURl(cartApi: customerCartApi)
}
else {
customerCartItemsDownloadJsonWithURl(cartApi: customerCartApi)
}
}else if (loginCheck == 0) || (loginCheck == nil) {
if let token = UserDefaults.standard.value(forKey: "user_token") {
self.key = token as? String
let defaultValue = UserDefaults.standard.value(forKey: "MenuButton") as? String
if (defaultValue == "Tab" && itemCode == nil) {
check = true
cartCountApiDownloadJsonWithURL(cartCountApi: getCartApi)
}
} else {
gettingKeyFromJsonWithURL(keyApi: keygettingApi)
}
if itemCode != nil && key != nil {
self.PostingKeyFromJsonWithURL(PostingApi: postingKeyApi)
}
if key != nil {
cartCountApiDownloadJsonWithURL(cartCountApi: getCartApi)
emptyView.isHidden = true
}
}
}

Here is my home page enter image description here

最佳答案

viewWillApear() 方法比使用通知或委托(delegate)或相关的方法更适合重新加载 View 。只需将您想要重新加载的代码放入 viewWillApear()

关于ios - 从 swift 3 中的标签栏移动时如何重新加载页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47647288/

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