我正在使用 Storyboard在 ios 中创建一个应用程序。我有一个选项卡栏 Controller 作为我的 Root View ,从这个页面我可以使用选项卡导航到其他页面,但是我如何在选项卡栏 Controller 的 Root View 中插入任何文本或图像。
最佳答案
标签栏 Controller 的默认页面(或您所说的根页面)只是其他 UIViewController
之一。 UITabBarController
可以在其中显示另一个 UIViewController
。 UITabBarController
中不能有文本或图像,但可以有一个包含文本或图像的 UIViewController
。它只是其他 View Controller 的容器。
看看这个 example ,这将有助于简化事情。
FirstViewController *fistView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:fistView, secondView, nil];
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:YES];
在上面的代码中,firstView
Controller 最初将显示在 tabController
中,因此您要做的是在 中添加文本和图像等内容firstView
的 xib 文件(或代码)。
关于ios - 如何使用 Storyboard在 ios 的 Root View 中显示某些内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20048170/