[英]How to add a KVO to MPMoviePlayer currentPlaybackTime?
[英]How to add an Subview to a Fullscreen MPMoviePlayer
我想将徽标( UIImageView
)添加到全屏MPMoviePlayerController。
当MPMoviePlayerController
不在全屏模式下时,它可以正常工作。 当我切换到全屏模式时, MPMoviePlayerController
上的所有已添加视图MPMoviePlayerController
删除(隐藏)。
这是我的代码:
- (void)setupMPMoviePlayer{
[self.moviePlayer.view removeFromSuperview];
[self removeNotifications];
self.moviePlayer = nil;
self.moviePlayer = [[MPMoviePlayerController alloc] init];
[self addNotifications];
[self.moviePlayer.view setFrame:self.view.bounds];
self.moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.moviePlayer.fullscreen = NO;
[self.view addSubview:self.moviePlayer.view];
if ([self.moviePlayer respondsToSelector:@selector(setAllowsAirPlay:)])
[self.moviePlayer setAllowsAirPlay:YES];
[self.moviePlayer setContentURL:[NSURL URLWithString:urlString]];
[self.moviePlayer setFullscreen:YES animated:YES];
[self addLogoViewAtView:self.moviePlayer.view];
}
- (void)addLogoViewAtView:(UIView *)view{
UIView *theView = [view viewWithTag:101];
if (theView.superview) {
[theView removeFromSuperview];
}
UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_weiss.png"]];
logoView.tag = 101;
logoView.frame = CGRectMake( logoView.image.size.width - 100.0,
100.0,
logoView.image.size.width,
logoView.image.size.height);
logoView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
[view addSubview:logoView];
[view bringSubviewToFront:logoView];
}
现在我的问题是还有一种替代方法可以向MPMoviePlayerController
添加子视图吗?
我可以将徽标添加到应用程序的窗口中,但这不是很干净。
有人对我该怎么做有任何想法吗?
最可能的全屏模式是在应用程序的keyWindow处添加MPMoviePlayerController视图,或在上方显示模式视图控制器。 因此,您可以尝试在window.subviews或moviePlayer的模式视图控制器中查找视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.