JayVDiyk JayVDiyk - 1 year ago 121
Swift Question

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

Answer Source

If you are using storyboard

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

where SubclassOfAViewController is identifier.


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download