App Loading and Splash Screen
My app downloads quite a lot of data, which takes about a few seconds. My splash screen displays and then disappears and then a white blank screen appears for a few seconds before the first view is loaded. Is there a way to keep the splash screen appearing? Is it okay to create a view in the AppDelegate and keep it displayed until all the dat开发者_如何学Ca loading has been completed and the view is about to load?
Use MBProgressHUD You can get the whole source code here.
https://github.com/jdg/MBProgressHUD
Hope this helps.
This is a Loading View which is Activity Indicator.
EDIT:
You can add your background view into window while your data is being downloaded in background using
[window addSubview:<backgroundView>.view];
Then once data is downloaded, you can remove the same from window and add your main view controller into window
[<backgroundView>.view removeFromSuperView];
[window addSubview:<mainView>.view];
Hope this helps you.
YEs, you can display a view with a splash screen (and maybe an activity indicator, just remember to load your data in a separate thread, or it won't spin), then switch to the proper View when the loading is done.
The white view that you see before the actual view is the mainWindow. Sinply set the splash image as background image of your window in the MainWindow.xib, and you're done. Optionally you can also add a spinner that is always spinning on top of the window, so that when your app is loading you first see the splash screen, then the spalsh screen with the spinner and then your view appears.
I do load an ImageView with an default-Image in viewDidLoad and hide it if you the data is preceeded.
UIImage* imageDefault = [UIImage imageNamed:@"Default@2x.png"];
CGRect frame;
frame.origin.x = 0;
frame.origin.y = -20;
frame.size.width = 320;
frame.size.height = 480;
splash = [[[UIImageView alloc] initWithFrame:frame] autorelease];
[splash setImage:imageDefault];
[self.view addSubview:splash];
.
.
splash.hidden=YES;
精彩评论