Search code examples
iosswiftuitabbarcontrolleruitabbar

Load UITabBarController from Nib


How do we load a UITabBarController from NIB?

for UIViewControllers we could easily do this

        let viewController = SubclassOfViewController(nibName: "SubclassOfAViewController", bundle: nil);

But I could not find any similar method to load a UITabBarController which is from Nib

Any thoughts?

Thank you

Edit: I am not using Storyboards


Solution

  • If you are using storyboard

     let tabbarController = [[UIStoryboard storyboardWithName:@"Main"bundle:NULL] instantiateViewControllerWithIdentifier:@"SubclassOfAViewController"]; 
    

    where SubclassOfAViewController is identifier.

    Else

    let viewController = SubclassOfViewController(nibName: "SubclassOfAViewController", bundle: nil)
    

    This method is fine. Since UITabbarController is a subclass of UIViewController there is no need of separate method here in subclass