我知道,有几十个类似的问题。我读完了所有内容,但仍无法找到答案。
我通过presentModalViewController
方法显示带有视频的视图。当用户进行滑动时,我希望下一个视频可以在同一个播放器中启动。但是当我尝试更改视频播放器的contentURL
时,视图会消失 - 就像调用了dismissModalViewControllerAnimated
方法一样(但事实并非如此)。
@implementation ViewController
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(!moviePlayerViewController)
{
NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"];
moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
UISwipeGestureRecognizer *leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)];
leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[moviePlayerViewController.view addGestureRecognizer:leftSwipeRecognizer];
[self presentModalViewController:moviePlayerViewController animated:YES];
}
}
-(void)leftSwipe:(id)sender
{
moviePlayerViewController.moviePlayer.contentURL =
moviePlayerViewController.moviePlayer.contentURL; // no matter what exactly URL here.
[moviePlayerViewController.moviePlayer play]; // view disappears even before this line is reached
}
@end
答案 0 :(得分:0)
奇怪的是:我昨天花了整整一天试图找到一个徒劳的答案,我在这里发布问题后一分钟就找到了答案。
http://josebolanos.wordpress.com/2011/09/28/dismissing-mpmovieplayerviewcontroller-the-right-way/