本文介绍了MPMoviePlayerController存在黑色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作iOS应用.
我使用MPMoviePlayerController,但这显示黑色背景.
我认为可以通过此URL解决此问题,但我无法理解使用方式.
MPMoviePlayerController背景色不会变
我的代码是这个.
I make iOS app.
I use MPMoviePlayerController, but this shows black background.
I think this problem can solve by this URL, but I can't understand use way.
MPMoviePlayerController background color won't stick
My code is this.
NSString *path = [[NSBundle mainBundle] pathForResource:@"movie_files" ofType:@"m4v"];
NSURL *videoURL = [NSURL fileURLWithPath:path];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:videoURL];
//setting
moviePlayer.scalingMode =MPMovieScalingModeAspectFit;
moviePlayer.controlStyle=MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay=NO;
[moviePlayer.view setFrame:CGRectMake(20, 20, 280, 200)];
//notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
//clearColor
UIView *subV =[[UIView alloc]init];
for(subV in moviePlayer.backgroundView.subviews) {
subV.backgroundColor = [UIColor clearColor];
}
[moviePlayer.view addSubview:subV];
[self.view addSubview:moviePlayer.view];
//show white screen
请告诉清楚背景方式.
推荐答案
您需要将其更改为:
moviePlayer.backgroundView.backgroundColor = [UIColor clearColor];
for(UIView *aSubView in moviePlayer.view.subviews) {
aSubView.backgroundColor = [UIColor clearColor];
}
这篇关于MPMoviePlayerController存在黑色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!