views:

234

answers:

1

I am trying to add a UITabBarController to a UIViewController:

[self.view addSubView:tabBarController.view];

I get a warning:

warning: 'UIView' may not respond to '-addSubView:'

How can I add a UITabBarController to my UIViewController?

+1  A: 

The specific warning you are getting is because you are spelling the method name wrong; try addSubview: instead of addSubView:.

But, aside from that problem, you may still have difficulty getting the UITabBarController to work correctly in a subview, because it's not intended to be used that way. The UITabBarController Class Reference says:

When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

David Gelhar
What happens if I add it as a subview of a ViewController and now the root of my window?
Sheehan Alam
This question http://stackoverflow.com/questions/1329560/adding-a-tabbarcontroller-as-the-subview-of-a-view might give you some pointers on what you you might run into and how to work around it.
David Gelhar