iPhone / iPad:动画闪屏?

时间:2011-05-29 19:05:27

标签: iphone objective-c ipad

我想创建一个动画徽标,作为我的iphone / ipad应用的启动画面。

我正在考虑显示default.png,然后转换为.mp4(.mp4的第一帧与default.png匹配),播放3秒的电影,淡出并加载我的应用程序

有没有人有这方面的经验?我的想法(使用.mp4)是实现这一目标的最佳方法吗?此外,苹果公司“很酷”吗?

提前致谢。

3 个答案:

答案 0 :(得分:2)

是的,你绝对可以做到这一点,是的,Apple很酷。

你可以使用MPMoviePlayerController,将它放在带有启动图像的UIImageView下,当电影加载完毕并准备去除UIImageView并播放电影时。

但鉴于MPMoviePlayerController有时很挑剔,你需要仔细考虑时间。这是一个可以作为起点的片段:

-(void)setupMovie {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:self.playerView];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playMovie:)
                                                 name:MPMoviePlayerLoadStateDidChangeNotification object:self.playerView];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showMovie:)
                                                 name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.playerView];

    [self.playerView setContentURL:[[NSBundle mainBundle] URLForResource:@"movie" withExtension:@"mov"]];
    [self.playerView prepareToPlay];
}


-(void)playMovie:(NSNotification *)notification {
    if (self.playerView.loadState == MPMovieLoadStatePlayable | MPMovieLoadStatePlaythroughOK) {
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:notification.object];
        [self.playerView play];     
    }
}

-(void)showMovie:(NSNotification *)notification {
    if (self.playerView.playbackState == 1) {
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:notification.object];
        // should update this to new UIView anim methods
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:.2];
        self.splashScreen.alpha = 0;
        [UIView commitAnimations];      
    }
}

答案 1 :(得分:0)

我认为像这样的教程可能会有所帮助:http://www.youtube.com/watch?v=wCsumlHiEc0&feature=channel_video_title

答案 2 :(得分:0)

回应UIApplicationDidFinishLaunchingNotification。我同意@jhocking你应该考虑这样的等待是否是最好的用户体验,但如果确实如此,这是一个非常简单的任务。