Adding Navigation Bar on Tab-Bar Based App

I have a tab-bar based app and I want to add Navigation Bar at the top of the app. Please note that I am using a library called PageMenu that creates 2 TableViews inside 1 parent ViewController.

What I tried was, adding a new ViewController and Editor->Embed in Navigation Bar. Place it before Tab Bar Controller, ctrl+drag to Tab Bar Controller to set the relationship of root view. Finally set Nav Bar Controller as initial view controller. But this fails like this:

  • Why does my version of filter perform so differently than Swifts?
  • iOS App Freezes on PushViewController
  • Swift 3: Caching images in a collectionView
  • iOS App Promotion Code expiration conditions
  • iOS 8 - change character spacing on UILabel within Interface Builder
  • iPhone: What gets called after viewDidLoad before viewWillAppear?
  • enter image description here

    (Top became pretty weird, blurry and the sub-header of PageMenu got disappeared. Maybe it’s under that blurry thing because I can still swipe between 2 table views.

    enter image description here

    Secondly, I tried removing the Navigation Controller, and add Navigation Bar to the ViewControllers manually. This worked for table view and view controllers but not the PageMenu one. When I tried it on PageMenu Controller, it didn’t show any navigation bar.

    Please note that, in the Demo, they used Navigation Bar as Parent and sub-TableViews, and they achieved Navigation Bar with this as well as Storyboard > Navigation Controller:

    override func viewDidLoad() {
        super.viewDidLoad()
    
        self.title = "HEADER"
        self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
        self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
      }
    

    Lastly, I tried..

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    
        let nav1 = UINavigationController()
        let first = ViewController(nibName: nil, bundle: nil)
        nav1.viewControllers = [first]
    
        let second = SecondViewController(nibName: "SecondViewController", bundle: nil)
        let nav2 = UINavigationController()
        nav2.viewControllers = [second]
    
        let tabs = UITabBarController()
        tabs.viewControllers = [nav1, nav2]
    
        self.window!.rootViewController = tabs;
        self.window?.makeKeyAndVisible();
    
        return true
    }
    

    But the result I get is:

    enter image description here

    What I want to achieve (but with TabBarController; NavBar just for header):

    enter image description here

    What I have now is this. I just want to add NavigationBar at the top of it like the above PageMenu example

    enter image description here


    Update:
    Lasly, I also tried:
    enter image description here

    But same issue:
    enter image description here

    2 Solutions Collect From Internet About “Adding Navigation Bar on Tab-Bar Based App”

    You can also create like wise story board that helps to solve your problem.

    enter image description here

    Here I can created sample code what you want no single line code change but changes into storyboard only.

    Download source code from here.

    Check this image

    Not add Editor->Embed in Navigation Bar before Tab Bar Controller
    add Editor->Embed in Navigation Bar before of View controller which you connect from Tab Bar controller.

    Because its work for particular Tab Vise so we have to add Editor->Embed in Navigation Bar before of View controller