我知道,有几十个类似的问题。我全部阅读了它们,但仍然找不到答案。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