我在标题中描述了警告,但我发现这是多次调用viewDidLayoutSubviews
的结果。
- (void) viewDidLayoutSubviews
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"wq" ofType:@"mp4"]];
self.playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:self.playerController];
[self.playerController.moviePlayer prepareToPlay];
self.playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
self.playerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.playerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
self.playerController.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self.playerController.view setFrame:self.movieView.bounds];
[self.movieView addSubview:self.playerController.view];
[self.playerController.moviePlayer play];
}
我也试过在(void) loadView
中使用上面的代码,但结果是一样的。
我在故事板中也有一些按钮,我不想错过它们。
任何人都可以帮我只有一个MPMoviePlayerViewController吗?
提前致谢!