0

我想向UIImageView全屏 MPMoviePlayerController 添加一个 Logo ()。

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吗?

我可以将徽标添加到应用程序的窗口,但这不是很干净。

有人知道我该怎么做吗?

4

1 回答 1

0

最合适的全屏模式在 keyWindow 为应用程序添加 MPMoviePlayerController 视图或在上面显示模态视图控制器。因此,您可以尝试在 window.subviews 或moviePlayer 的模态视图控制器中查找视图。

于 2012-11-28T11:25:38.293 回答