ios - 如何使用 Storyboard在 ios 的 Root View 中显示某些内容?

标签 ios storyboard uitabbarcontroller

我正在使用 Storyboard在 ios 中创建一个应用程序。我有一个选项卡栏 Controller 作为我的 Root View ,从这个页面我可以使用选项卡导航到其他页面,但是我如何在选项卡栏 Controller 的 Root View 中插入任何文本或图像。

最佳答案

标签栏 Controller 的默认页面(或您所说的根页面)只是其他 UIViewController 之一。 UITabBarController 可以在其中显示另一个 UIViewControllerUITabBarController 中不能有文本或图像,但可以有一个包含文本或图像的 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/

相关文章:

iphone - 按钮相对于彼此的定位

ios - 推送到任何 viewController 时始终显示 tabBarController

ios - TabBarController 和 TableView

ios - 以下swift代码是什么意思?

iphone - 从在线 Plist 文件中获取字符串?

ios - iPad 模拟器的高度似乎过高

ios - 在 Storyboard 中以模态序列传递数据?

iphone - 不使用 UINavigationController 在 UITabbarController 中显示完整 View

ios - 无法在 SQLite 中截断和删除表

ios - KVO 观察 AVPlayer 导致 iOS 13 中的 App 崩溃