Objective c MPMoviePlayerViewController帧大小
我有这个方法:Objective c MPMoviePlayerViewController帧大小,objective-c,ios,Objective C,Ios,我有这个方法: -(void) playMov: (NSString*) title{ // play a movie!! NSString *movpath = [[NSBundle mainBundle] pathForResource:title ofType:@"mp4"]; self.mpviewController =[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:mov
-(void) playMov: (NSString*) title{
// play a movie!!
NSString *movpath = [[NSBundle mainBundle] pathForResource:title ofType:@"mp4"];
self.mpviewController =[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:movpath]];
[self.mpviewController.view setFrame: CGRectMake(0, 0, self.view.frame.size.width, 275)];
self.mpviewController.view.backgroundColor = [UIColor clearColor];
[self.mpviewController.view setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:mpviewController.view];
MPMoviePlayerController *mp = [mpviewController moviePlayer];
mp.contentURL = [NSURL fileURLWithPath:movpath];
CGRect playerFrame = CGRectMake(0, 0, self.view.frame.size.width, 275);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:mp];
[mp.view setFrame:playerFrame];
mp.view.backgroundColor = [UIColor clearColor];
[mp prepareToPlay];
[[mpviewController moviePlayer] play];
}
第一次加载视图时,它是黑色背景的全屏视图。
第一次之后是在想要的大小(0,0,self.view.frame.size.width,275)上仍然是黑色背景。
我希望它是这样的大小和清晰的背景色每一次
有什么想法吗?尝试使用
MPMoviePlayerController
类的backgroundView
属性。UIImageView*imgView=[[UIImageView alloc]initWithImage:backimage];[[mp backgroundView]添加子视图:imgView];工作:)