加载所有TabBar视图 [英] Load All TabBar Views

查看:190
本文介绍了加载所有TabBar视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tabbar控制器作为根视图控制器。我想预先加载tab [1,2,3]的视图(tab 0自动加载为第一个标签)。

I have a tabbar controller as the root view controller. I would like to pre-load the views of tab [1,2,3] (tab 0 loads as the first tab automatically).

我基本上想要代码在viewdidload中,在用户点击选项卡之前运行。

I essentially would like the code in viewdidload to run before the user taps on the tab.

谢谢

推荐答案

如果您使用视图初始化代码并将其移动到loadView而不是viewDidLoad,则可以通过简单地调用viewController.view来强制加载属于UITabBarController一部分的每个UIViewControllers。发生这种情况是因为UIViewController会在被要求时通过loadView函数创建视图对象。

If you take your view initialization code and move it into loadView instead of viewDidLoad you can force each of the UIViewControllers that are part of your UITabBarController to be loaded by simply calling viewController.view. This happens because a UIViewController will create the view object via the loadView function when asked for it.

for(UIViewController * viewController in  tabBarController.viewControllers){
   viewController.view;
}

或更简单

[tabBarController.viewControllers makeObjectsPerformSelector:@selector(view)];

这篇关于加载所有TabBar视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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