Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在演示过程中尝试演示MPMoviePlayerViewController_Ios_Mpmovieplayercontroller_Viewdidlayoutsubviews - Fatal编程技术网

Ios 在演示过程中尝试演示MPMoviePlayerViewController

Ios 在演示过程中尝试演示MPMoviePlayerViewController,ios,mpmovieplayercontroller,viewdidlayoutsubviews,Ios,Mpmovieplayercontroller,Viewdidlayoutsubviews,我得到了标题中描述的警告,我发现这是多次调用viewdilayoutsubviews的结果 - (void) viewDidLayoutSubviews { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"wq" ofType:@"mp4"]]; self.playerController = [[MPMoviePlayerViewController alloc]initWithConte

我得到了标题中描述的警告,我发现这是多次调用
viewdilayoutsubviews
的结果

- (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
中使用上述代码,但结果是一样的。 我也有一些按钮在故事板,我不想错过他们。 谁能帮我只用一个MPMoviePlayerViewer控制器


提前谢谢

最后我用这个解决了这个问题。谢谢timquinn!