开发者

How to add a subview to a UIViewController?

开发者 https://www.devze.com 2023-01-02 18:49 出处:网络
I am trying to add a UITabBarController to a UIViewController: [self.view addSubView:tabBarController.view];

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?


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.


*emphasized text*replace with this----

[self.view addSubview:obj.view];

0

精彩评论

暂无评论...
验证码 换一张
取 消