多个启动画面

时间:2011-02-17 05:46:21

标签: iphone

所以我有一个需要2个启动画面的iPhone应用程序。

在第一个中,我需要检查我的sqlite数据库是否存在,并且具有特定表的所有正确值。 3秒后,第二个闪屏应该开启,再过3秒后,我的第一个视图出现了。

我已经有了一个root控制器,它的类型为UITabBarController。所以我只需要确保第二个启动画面完成后的加载。我已经知道我需要一个UIImageView,但我不知道我应该把它放在哪里或者我应该怎么做。我的两张图片名为

splash1_placeholder.png和splash2_placeholder.png它们都是480x320px

1 个答案:

答案 0 :(得分:3)

为什么3秒?为什么不“直到我的方法完成?”人们讨厌闪屏。这就是苹果(以及其他所有人)不鼓励使用它们的原因。

也许你应该加快你的配置逻辑 当他们坐在公交车上并希望在接下来的30秒内使用你的应用程序时,没有人想要读取你的公司名称6秒(加上显示真正的默认飞溅图像的时间)。


无论如何,这是你如何实现它:

找到将tabbarcontroller添加到窗口的代码,将其替换为第一个splashscreen图像 设置一个方法,该方法在3秒后触发,从窗口中移除第一个启动并添加第二个启动 再过3秒后,从窗口中删除第二个启动画面,最后添加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];
}

并非完全完美,但您可以将其作为起点 例如,不需要删除第一个UIImageView,您只需替换图像即可。不知道为什么我认为我应该删除它。

相关问题