skip to Main Content

I created a Tab Bar Controller, with 4 navigation controllers each containing one view controller, but on these view controllers, the bar titles are super low. It doesn’t matter if I choose large title or not, the issue is the same with regular titles.
Is it because of the tab bar?

f

largetitles

smalltitles

Does someone knows how to fix it? When I set a custom frame for the navigation bar it doesn’t have any influence.
And when I push a new view controller, we can’t interact with anything that’s in the first 25% of the screen (probably because it’s behind the navigation bar title, even when i set it to none). That’s really weird, how do I set the titles higher or just disable them?

This is also what’s in my scene delegate :

let storyboard = UIStoryboard(name: "TabBar", bundle: nil).instantiateViewController(withIdentifier: "Main") as! UIViewController
let navigation = UINavigationController(rootViewController: storyboard)
window?.rootViewController = navigation
window?.makeKeyAndVisible()

The view controller with Identifier ‘Main’ is actually to tab bar at the top of the storyboard, so maybe there’s an issue with my scene delegate, but I don’t know why this could have an influence on the position of the navigation bar.

2

Answers


  1. enter image description here

    Check if you have selected Prefers Large Titles (If then uncheck it).

    Login or Signup to reply.
  2. This code from your question:

    // instantiate the UITabBarController with identifier "Main"
    //  from Storyboard named "TabBar"
    let storyboard = UIStoryboard(name: "TabBar", bundle: nil).instantiateViewController(withIdentifier: "Main") as! UIViewController
    
    // create a new UINavigationController, with the 
    //  instantiated UITabBarController as its Root View Controller
    let navigation = UINavigationController(rootViewController: storyboard)
    
    // show the navigation controller
    window?.rootViewController = navigation
    window?.makeKeyAndVisible()
    

    So, you have:

    • a Navigation Controller (with its own navigation bar)
    • holding a Tab Bar Controller
    • each tab has its own navigation controller and navigation bar

    Change your code to this (although it is very confusing object naming):

    // instantiate the UITabBarController with identifier "Main"
    //  from Storyboard named "TabBar"
    let storyboard = UIStoryboard(name: "TabBar", bundle: nil).instantiateViewController(withIdentifier: "Main") as! UIViewController
    
    // show the tab bar controller
    window?.rootViewController = storyboard
    window?.makeKeyAndVisible()
    

    That said… why are you not setting that directly in your project setup? Why do this loading from code?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search