我有一个具有两个选项卡的主tabController,第一个选项卡被选择为默认选项卡。当按下tab2时,文件已加载到Web视图中,但是您必须等待几秒钟。在选择tab2之前如何加载内容?设置好tabController并正确执行后,我试图调用carrega(包含有效的ViewDidLoad代码)函数,但是,当选择tab2时,内容为空白...谢谢。
来自代表,
viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil];
[tabBarController setViewControllers:viewControllers animated:NO];
[self.window makeKeyAndVisible];
[firstVC carrega];
[secondVC carrega];
//now few seconds later, tab2 will be pressed and should have content already loaded!
第二个viewController,
-(void)carrega{
//here my loading content code that if is on ViewDidLoad works great but with loading timeout
}
最佳答案
尝试
viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil];
[tabBarController setViewControllers:viewControllers animated:NO];
[self.window makeKeyAndVisible];
[secondVC view];
强制加载第二个视图。
关于iphone - xcode加载tabContent选择之前,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10173284/