在我的rootviewcontroller
中,导航菜单下面有三个选项卡,每个选项卡代表一个产品列表,在导航菜单中,我有一个购物车图标,上面有一个数字,以显示购物车中的图标数量。每个选项卡都是一个独立的viewcontroller
,它们在rootviewcontroller
中都是这样引用的:
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let layout = UICollectionViewFlowLayout()
let firstTab = FirstTabController(collectionViewLayout: layout)
let seccondTab = SeccondTabController(collectionViewLayout: layout)
let thirdTab = ThirdTabController(collectionViewLayout: layout)
return [firstTab ,seccondTab ,thirdTab ]
}
我在defaultviewcontroller
中创建了一个函数来重置导航菜单中的购物车编号,但我不知道如何从firsttabController
中启动此函数
这是我在firsttabcontroller
中的函数
func AddToCart(sender:UIButton) {
let activityIndicatorView = NVActivityIndicatorView(frame: self.view.frame, type: .circleStrokeSpin, color: .red, padding: 170)
self.view.addSubview(activityIndicatorView)
activityIndicatorView.startAnimating()
let parameters : [String: Any] = [
"productid": sender.tag ,
"quantityid": 1
]
ApiServiceCart.sharedInstance.addProductToCartCatalog(parameters: parameters) { (success) in
activityIndicatorView.removeFromSuperview()
if success == true {
// here i want to fire DefaultController().setupNavigationMenu()
self.displayMessage(Title: MessageTitle.Successfull.rawValue, Message: Message.AddToCart_Successfull.rawValue)
}
else {
self.displayMessage(Title: MessageTitle.Error.rawValue, Message: Message.AddToCart_Error.rawValue)
}
}
}
我尝试过协议委派,但不起作用
github.com/kavehnaseri/Protino/blob/master/Protino。我想从默认控制器调用的函数是(setupNavBarButtonsWithCartOnLeft) wichi在helper/extension+UIViewController中
https://stackoverflow.com/questions/50777311
复制相似问题