2011-05-29 86 views
0

我想創建一個動畫標誌,作爲我的iPhone/iPad應用程序的啓動畫面。iPhone/iPad:動畫閃屏?

我正在考慮顯示default.png,然後轉換爲.mp4(其中.mp4的第一幀與default.png匹配),播放3秒鐘的電影,淡出並加載我的應用。

有沒有人有這方面的經驗?我的想法(使用.mp4)是實現這一目標的最佳方式嗎?另外,蘋果是否「很酷」?

在此先感謝。

+2

我會建議重新考慮這一計劃,因爲3秒的動畫標誌(在那裏等待已經的頂部是靜態的啓動屏幕上)可能會導致一半人們甚至在完成加載之前退出你的應用程序。 – jhocking 2011-05-29 19:09:08

+0

我做了2-3秒的暫停(並且已經在多個應用程序中成功完成),所以不是靜態屏幕,我會假設用戶更喜歡審美動畫。 – foreyez 2011-05-29 19:11:24

+0

許多應用程序使用類似的動畫/電影。我認爲你很好。 – kball 2011-05-29 19:18:37

回答

2

是的,你絕對可以做到這一點,是的蘋果是很酷的。

您可以使用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];  
    } 
} 
0

響應的UIApplicationDidFinishLaunchingNotification。我同意@jhocking你應該考慮這樣的等待是否是最好的用戶體驗,但如果是這樣,這是一個非常簡單的任務。