我有一个UITabBarController管理一些UINavigationControllers,它反过来管理各种UIViewControllers的应用程序。预渲染UITabBarController视图?
在3G手机上,我第一次通过TabBar按钮查看任何特定的视图时,它是滞后的,但此后,它很活泼。这在3GS手机中并不明显。我的问题是如何强制这些视图进行预渲染?我尝试在启动时通过在不同的线程中调用loadView函数来触发loadView函数,但是这不会做任何我不认为的事情。
为了清楚起见,下面是我的代码中的一个缩写片段,用于显示我在做什么。我有五个视图控制器,但我只展示了两个代码。 poiVC只是一个标准的UITableViewController子类 - 我甚至没有自定义的init或loadView函数。
- (void)applicationDidFinishLaunching:(UIApplication *)application {
self.mapVC = [[MapViewController alloc] init];
NavControlBar * mapNavBar = [[[NavControlBar alloc] initWithViewController:mapVC
withControlBar:[mapVC initBar]]autorelease];
self.poiVC = [[POIViewController alloc] init];
NavControlBar * poiNavBar = [[[NavControlBar alloc] initWithViewController:poiVC
withControlBar:[poiVC initBar]]autorelease];
NSArray *tabViewControllerArray = [NSArray arrayWithObjects:mapNavBar, poiNavBar, nil];
self.tbc.viewControllers = tabViewControllerArray;
self.tbc.delegate = self;
[mapVC release];
[poiVC release];
[window addSubview:tbc.view];
}
我可以得到poiVC呈现在用户看第一屏,所以过渡将是快?
你为什么要明确创建导航栏?为什么不在视图控制器中使用navigationItem来管理导航栏?这可能是问题的一部分。 (什么是NavControlBar?) – Nimrod 2010-01-14 00:07:44
这些NavControlBars是我创建的一个哑类,用于在UINavigationBar中添加任意元素,然后才能理解UIBarButtonItems如何与自定义视图一起工作。以下是该类的github存储库:http://github.com/andrewljohnson/NavControlBar。我不认为这是问题...即使我使用正常的navigationControllers,视图也不会在第一次显示在屏幕上时呈现,并且在第一次加载时我仍会看到轻微的滞后。 – 2010-01-14 00:10:57