我已搜索但未找到我正在寻找的确切内容。我有一个UITabBar应用程序,在第一个视图中,从Web加载大量数据。这可能需要几秒钟,尤其是连接到Edge网络时。
我有一个显示徽标等的启动屏幕,但我想添加一个活动指示器来向用户显示某些内容确实在进行。
我怎样才能做到这一点?我发现的帖子只会在标签之间切换时考虑ActivityIndicators。
由于
答案 0 :(得分:0)
如果加载数据需要很长时间,你可以使用另一个视图控制器作为你的rootViewController只有Splashscreen(屏幕上有你可以显示的图像或视图,直到数据被下载)和活动指示器以及下载时完成从窗口中删除temprootViewcontroller并将原始控制器添加到窗口。
修改强>
//To show custom Splash screen do something like in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
SplashScreenVC *splashScreenVC = [[SplashScreenVC alloc] initWithNibName:@"SplashScreenVC" bundle:nil];
self.window.rootViewController = splashScreenVC;
[self.window makeKeyAndVisible];
//And when your data finishes downloading you can write following there to show your tabBar.
AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
delegate.window.rootViewController = delegate.tabBarController;
[delegate.window makeKeyAndVisible];
//If you want to simulate downloading and want to sleep the device you can try this in SplashScreenVC
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self performSelector:@selector(gotosleep) withObject:nil afterDelay:1.0];
}
-(void)gotosleep{
sleep(5);
AppDelegate*delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
delegate.window.rootViewController = delegate.tabBarController;
[delegate.window makeKeyAndVisible];
}