在我的應用程序中,我使用MPMoviePlayerController.my在第一類XIB中運行視頻,視頻durtion大約是20秒。我希望當我的視頻結束時自動調用第二類XIB.here是我的代碼。如何在運行時調用IPad中的第二個XIB?
-(void)viewWillAppear:(BOOL)animated
{
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:videoPlayer.view];
videoPlayer.view.frame = CGRectMake(0, 0,768, 1000);
[videoPlayer play];
[self performSelector:@selector(gotonextview)];
}
-(void)gotonextview
{
secondview *sec=[[secondview alloc] initWithNibName:@"secondview" bundle:nil];
[self presentModalViewController:sec animated:YES];
[sec release];
}
此代碼給我沒有錯誤,但它沒有在視頻完成後調用第二類。任何機構指導我。提前Thanx
「不要叫viewWillAppear中而不是gotonextview註冊您的視圖控制器作爲MPMoviePlayerPlaybackDidFinishNotification和MPMoviePlayerDidExitFullscreenNotification在viewDidLoad中與gotonextview觀察員:(NSNotification *)通知的選擇。」確保您在viewDidLoad NOT viewDidAppear中註冊了這些通知... viewDidAppear用於開始播放。 –
thanx的回覆所以for.i我無法理解你的方法可以請您使用我的代碼編輯您的答案..thanx – jamil
我已適應您的代碼並編輯我的原始帖子。它沒有經過測試,但至少應該把你放在正確的軌道上。請閱讀蘋果文檔以獲取更多關於使用的MPMoviePlayerController和NSNotification –