完成播放视频后如何移动到另一个ViewController?从'2'到'1'(查看截图)
viewDidLoad
(videoViewControler
)中的代码:
NSURL *url = [NSURL URLWithString:@"_http://scontent-a.cdninstagram.com/hphotos-xfa1/t50.2886-16/10619021_616434485141882_380154097_n.mp4"];
videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[videoPlayer.moviePlayer prepareToPlay];
[videoPlayer.moviePlayer play];
[self presentMoviePlayerViewControllerAnimated:videoPlayer];
NSArray *viewControllers = [[self navigationController] viewControllers];
[self.navigationController popToViewController:viewControllers[1] animated:NO];
答案 0 :(得分:0)
为MPMoviePlayerPlaybackDidFinishNotification添加一个观察者,它将在电影结束时通知您,然后您可以回弹视图控制器。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
答案 1 :(得分:0)
您必须注册完成结束通知,例如在viewDidLoad:
中// Register for finished notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moveToView2:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayerViewController.moviePlayer];
添加通知方法并调用segue转到另一个视图:
- (void) moveToView2:(NSNotification *) notification {
[self performSegueWithIdentifier:@"IDENTIFIER" sender:self];
}
只需确保将IDENTIFIER替换为视图A和B之间的segue标识符。