我想在我的应用程序中添加一个标签栏。我添加了标签栏的页面不断刷新自身。我的customAnimateRemindStyle3()
函数一直在被调用。我该怎么办?
class MainTableViewController: UITableViewController, UITabBarControllerDelegate {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.present(AppDelegate.customAnimateRemindStyle3(implies: false), animated: false, completion: nil)
}
}
class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegate {
static func customAnimateRemindStyle3(implies: Bool) -> ExampleNavigationController {
let tabBarController = ESTabBarController()
if let tabBar = tabBarController.tabBar as? ESTabBar {
tabBar.itemCustomPositioning = .fillIncludeSeparator
}
let v1 = MainTableViewController()
let v2 = MainTableViewController()
let v3 = MainTableViewController()
let v4 = MainTableViewController()
let v5 = MainTableViewController()
v1.tabBarItem = ESTabBarItem.init(ExampleAnimateTipsContentView3(), title: nil, image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v2.tabBarItem = ESTabBarItem.init(ExampleAnimateTipsContentView3(), title: nil, image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
v3.tabBarItem = ESTabBarItem.init(ExampleAnimateTipsContentView3.init(specialWithAutoImplies: implies), title: nil, image: UIImage(named: "photo_big"), selectedImage: UIImage(named: "photo_big_1"))
v4.tabBarItem = ESTabBarItem.init(ExampleAnimateTipsContentView3(), title: nil, image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
v5.tabBarItem = ESTabBarItem.init(ExampleAnimateTipsContentView3(), title: nil, image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
tabBarController.viewControllers = [v1, v2, v3, v4, v5]
if let tabBarItem = v2.tabBarItem as? ESTabBarItem {
DispatchQueue.main.asyncAfter(deadline: .now() + 2 ) {
tabBarItem.badgeValue = "1"
}
}
let navigationController = ExampleNavigationController.init(rootViewController: tabBarController)
return navigationController
}
}
答案 0 :(得分:2)
之所以会这样,是因为您要在
ExampleNavigationController
的{{1}}上展示一个包含MainTableViewController
的新ViewWillAppear
简单地说,您是递归,要求一遍又一遍地展示MainTableViewController
您可以在这里做
首先删除此行表格MainTableViewController
ViewWillAppear
然后在应用程序代理中显示self.present(AppDelegate.customAnimateRemindStyle3(implies: false), animated: false, completion: nil)
以
TabBarController