0

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

1 回答 1

0

奇怪的事情:我整个昨天都在徒劳地寻找答案,我在这里发布问题后一分钟找到了答案。

http://josebolanos.wordpress.com/2011/09/28/dismissing-mpmovieplayerviewcontroller-the-right-way/

于 2012-06-15T07:33:37.027 回答