您可以張貼通知,根據用戶類型刷新選項卡,首先設置觀察員MainTabBarController,一旦通知檢查用戶類型並刷新標籤
extension Notification.Name {
static let refreshAllTabs = Notification.Name("RefreshAllTabs")
}
class MainTabBarController: UITabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(forName: .refreshAllTabs, object: nil, queue: nil) { (notification) in
//check if its a normal user or comapny user
if AppUser.shared.type == .normal {
self.viewControllers = [VC1, VC2, VC3, VC4, VC5]
} else {
self.viewControllers = [VC1, VC2, VC3, VC4]
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
now for post荷蘭國際集團每當用戶類型的變化只是叫
NotificationCenter.default.post(Notification(name: .refreshAllTabs))
我覺得第一行是不夠..:d。它只是看起來如此小的答案,導致你添加另一行。 – rptwsthi
只是確保:D –