开发者

Multiple Splash Screens

So I have an iPhone app that needs to have 2 splash screens.

During the first one I need to check if my sqlite database is there and has all the correct values for a specific table. After 3 seconds, the second splash screen should fire, after another 3 seconds, my first view comes up.

开发者_开发技巧

I already have a rootcontroller, its of type UITabBarController. So I just need to make sure that loads after the second splash screen completes. I already know I need a UIImageView but I dont know where I should put it or how I'm supposed to go about it. The two images I have are named

splash1_placeholder.png and splash2_placeholder.png they are both 480x320px


Why 3 seconds? Why not "until my methods complete?" People hate splash screens. That's why apple (and everybody else) discourages from using them.

Maybe you should speed up your configuration logic.
Nobody wants to read your company name for 6 seconds (plus the time the real default splash image will be displayed) when they sit in the bus and want to use your app for the next 30 seconds.


Anyway, here is how you would implement it:

Find the code where you add the tabbarcontroller to the window, replace it with the first splashscreen image.
Set up a method that fires after 3 seconds that removes the first splash from the window and adds the second one.
After another 3 seconds you remove the second splash screen from the window and finally add your tabbarcontroller.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    UIImageView *imageView = [[[UIImageView alloc] initWithFrame:self.window.bounds] autorelease];
    UIImage *image = [UIImage imageNamed:@"splash1_placeholder.png"];
    if (!image) {
        NSLog(@"Something went wrong trying to get the UIImage. Check filenames");
    }
    imageView.image = image;
    [self.window addSubview:imageView];
    [self.window makeKeyAndVisible];
    [self performSelector:@selector(removeFirstSplash:) withObject:imageView afterDelay:3];
    return YES;
}

- (void)removeFirstSplash:(UIImageView *)oldImageView {
    UIImageView *imageView = ...
    [self.window addSubview:imageView];
    [self performSelector:@selector(removeSecondSplash:) withObject:imageView afterDelay:3];
    [oldImageView removeFromSuperView];
}

- (void)removeSecondSplash:(UIImageView *)oldImageView {
    [self.window addSubview:self.tabController.view];
    [oldImageView removeFromSuperView];
}

not entirely perfect, but you could use it as a starting point.
For example there is no need to remove the first UIImageView, you could just replace the image. Don't know why I thought I should remove it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜