How to add navigation interface after create a tab bar controller programmatically (Swift)

前端 未结 1 570
孤独总比滥情好
孤独总比滥情好 2020-12-10 09:36

How do I add a navigation interface programmatically on Swift after I created a TabBarController on AppDelegate/didFinishLaunchingWithOpt

相关标签:
1条回答
  • 2020-12-10 09:57

    To create a navigation controller use:

    var navigationController = UINavigationController(rootViewController: viewController));
    

    Then just put it in the array:

    tabBarController.viewControllers = [purchaseViewController, financeViewController, navigationController]
    

    But, you can to add UIControls to navigation bar only after view controller did load. On applicationDidFinishLaunching: it's impossible, because the navigationBar is nil. Proper way is to add controls to navigationBar in the viewDidLoad()

    0 讨论(0)
提交回复
热议问题