有没有一个好的UITabBarController示例? [英] Is there a good UITabBarController Example?

查看:152
本文介绍了有没有一个好的UITabBarController示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个好的UITabBarController示例,它在

Is there a good UITabBarController example where it is NOT created in the appDelegate?

我想使用UITabBarController UIViewController,但不知道如何设置视图出口。

I would like to use a UITabBarController inside of a UIViewController, however dont know how to set the view outlet.

推荐答案

这是所有很好地记录在这里。它不应该在哪里创建UITabBarController实例,UIApplicationDelegate或不。简而言之,创建所有相应的UIViewController并将它们添加到数组。然后将该数组分配给您的UITabBarController的viewControllers属性。然后你可以简单地做一些 [window addSubview:myTabBarController.view]

This is all very well documented here. It shouldn't matter where the UITabBarController instance is created, UIApplicationDelegate or not. In a nutshell, Create all of your respective UIViewController's and add them to an array. Then assign that array to your UITabBarController's viewControllers property. Then you can simply do something like [window addSubview:myTabBarController.view].

从这里的文档粘贴:


您不应该直接访问选项卡栏控制器的标签栏
视图。
要配置选项卡栏的选项卡
控制器,您可以为viewControllers
属性分配视图
控制器,为每个选项卡提供根视图

指定视图控制器的顺序
决定它们
在标签栏中的显示顺序。当设置
这个属性时,你还应该为selectedViewController
赋值
,以指示最初选择哪个视图
控制器。 (你
也可以通过
数组索引使用selectedIndex
属性选择视图控制器。)当嵌入标签栏
控制器的视图(使用
继承视图属性)在
应用程序窗口中,标签栏
控制器自动选择
视图控制器并显示其
内容,根据需要将其大小调整为
适合标签栏接口。

You should never access the tab bar view of a tab bar controller directly. To configure the tabs of a tab bar controller, you assign the view controllers that provide the root view for each tab to the viewControllers property. The order in which you specify the view controllers determines the order in which they appear in the tab bar. When setting this property, you should also assign a value to the selectedViewController property to indicate which view controller is selected initially. (You can also select view controllers by array index using the selectedIndex property.) When you embed the tab bar controller’s view (obtained using the inherited view property) in your application window, the tab bar controller automatically selects that view controller and displays its contents, resizing them as needed to fit the tab bar interface.

这篇关于有没有一个好的UITabBarController示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆