我的iOS应用程序在启动时通过RestKit加载数据。有时需要时间才能在加载数据之前显示主窗口。如何在加载过程中显示启动画面并在所有数据加载完成后显示主窗口? 我可以在加载所有数据时调用方法或生成事件。
答案 0 :(得分:4)
您应该创建与ImageView
相同的ViewController到启动画面,并在viewDidLoad()
调用
self.presentViewController(splashScreenVC, animated: false, completion: nil)
加载数据时会关闭splashScreenVC
self.dismissViewControllerAnimated(false, completion: nil)
答案 1 :(得分:1)
同意这一点,但我会更详细地回答:
- (IBAction)goDownload:(id)sender {
//loading simulation
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Splash"];
[self.navigationController presentViewController:vc animated:NO completion:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Run a background thread
sleep(10);
[self.navigationController dismissViewControllerAnimated:vc completion:nil];
});
}
同时制作源代码:https://yadi.sk/d/W83sU-HrcREpE
答案 2 :(得分:-8)
对于Appdelegate.m中的真正简单修复,应用程序didFinishLaunching方法放
sleep(3)
在顶部播放数字,直到您对数据通常加载时感到满意为止。