-2

Is it possible and if so how can I use the UITabBarController in a class other than the appdelegate class?

Unix Mac
  • 83
  • 8
  • You can use it the same way like an ordinary viewController because tabBarController is inherited from it. Doesn't it work? – Miroslav Jan 08 '14 at 14:58
  • could you say what do you want accomplish so I could be more specific in my answer then – Julian Jan 08 '14 at 15:23

3 Answers3

0

Since UITabBarController is inheriting UIViewController, you can use it like a normal UIViewController, outside of AppDelegate class. The question is what you are trying to accomplish. For instance, you can present UITabBarController modally or push it to the screen using UINavigationController.

Julian
  • 9,299
  • 5
  • 48
  • 65
Rinat Khanov
  • 1,566
  • 10
  • 32
  • Here is what i am doing: I create a new class and select tabbarcontroller as the superclass and it gives me 3 new files .h .m .xib, then i drag a uitabbarcontroller onto the screen and wire it up but when i run the app i only see the blank view. I do not see the tabbarcontroller i added??? – Unix Mac Jan 08 '14 at 15:09
  • a little more info. I am using a uinavigation controller as my root view controller – Unix Mac Jan 08 '14 at 15:10
  • A UITabBarController can't be a child view controller of another view controller, according to Apple's documentation. So you can't push a UITabBarController on to a UINavigationController. You can however have a UINavigationController inside a UITabBarController. You could also present a UITabBarController modally like you said in your answer. – Gavin Jan 08 '14 at 15:15
  • Ok let me explain a little more. I have a sliding drawer that slides left and right. The navigation controller is on the main drawer which has a tab bar controller on it. I set the navbar controller + the tabbar controller in the appdelegate. However when i slide to the left i would like to add another tabbar controller to the bottom of that view. Is that possible or too many different controllers? – Unix Mac Jan 08 '14 at 15:26
0

I assume that you have a UITabBarController defined in AppDelegate. If you really want to do sth with that tab bar in other class (for example UIViewController) you can access AppDelegate like this:

[[UIApplication sharedApplication] delegate];

and then via property or methods you can access this tab bar. More examples

Community
  • 1
  • 1
Julian
  • 9,299
  • 5
  • 48
  • 65
0

Ok I found out how to fix it. I simply added a uitabbarcontroller programmatically vs IB and all is well. Thanks for the responses!

Unix Mac
  • 83
  • 8