Reputation: 335
In my case, I'm making an app for real-time chat. I'm using large titles and search bar inside of my main view. However I wanted to add tabBar to my app navigationController and tabBar not working correct.
NOTE: I'm doing everything with code, please not tell me about storyboard.
Here is what supposed to be:
What is happening when I add tabBar:
AppDelegate.swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
FirebaseApp.configure()
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: TabBarController())
return true
}
TabBarController.swift:
override func viewDidLoad() {
super.viewDidLoad()
let messagesController = UINavigationController(rootViewController: MessagesController())
messagesController.tabBarItem.title = "Sohbetler"
messagesController.tabBarItem.image = UIImage(named: "chats")
viewControllers = [messagesController]
}
Upvotes: 1
Views: 1362
Reputation: 121
try the following line in your viewcontroller where you want to show the tabbar
self.tabBarController?.tabBar.isHidden = false
Upvotes: 0
Reputation: 3016
You put two navigation one for tabbar and second for controller hide one navigation bar and your problem will solve
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
FirebaseApp.configure()
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let objNav = UINavigationController(rootViewController: TabBarController())
objNav.isNavigationBarHidden = true
window?.rootViewController = objNav
return true
}
Upvotes: 1