1

我試圖在服務器上打開視頻文件。在iOS上使用MPMoviePlayerViewController顯示視頻文件6

它使用此代碼適用於< 6.0罰款:

NSURL *videoURL = [NSURL URLWithString:[[[[self.campArray objectAtIndex:button.tag]valueForKey:@"images"]objectAtIndex:0]valueForKey:@"imageURL"]]; 
self.moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL]; 
self.moviePlayer.moviePlayer.shouldAutoplay=YES; 
[self presentModalViewController:self.moviePlayer animated:YES]; 
[self.moviePlayer.moviePlayer play]; 
[self.moviePlayer release]; 

而是試圖運行,其具有的iOS 6的設備上這種代碼的情況下,模態視圖呈現,然後1秒後關閉。它不會粉碎...玩家模式視圖只是關閉... 我讀了這個,也加了@property (strong,nonatomic) MPMoviePlayerViewController *moviePlayer;,但它仍然沒有工作...

感謝您的任何幫助。

回答

2

您應該使用iOS 6.0中的presentViewController方法來呈現視圖控制器。 presentModalViewController在ios 6.0中已棄用。

+0

不適用於我。我仍然收到崩潰,說:「未捕獲的異常:試圖在轉換已經進行時開始從的模態轉換。等待viewDidAppear/viewDidDisappear以知道當前轉換已完成」 –

+0

@RishabhTayal你調用viewcontroller的viewdidload中的方法(這發生在viewController尚未出現時)...你需要等到viewcontroller出現(viewDidAppear/viewDidDisappear),這樣你才能呈現一個新的視圖控制器 – Pach

相關問題