iphone - 如果使用全屏,则无法在 MoviePlayer 中看到按钮

标签 iphone ios objective-c ipad mpmovieplayercontroller

下面是我用来播放电影的代码:

playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:theURL];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]];

float screenWidth = self.view.frame.size.width;
float screenHeight = self.view.frame.size.height;
[playerViewController.view setFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[self.view addSubview:playerViewController.view];
[self.view setUserInteractionEnabled:YES];

//---play movie---
player = [playerViewController moviePlayer];
[player setControlStyle:MPMovieControlStyleNone];
[player setFullscreen:TRUE];
[player play];

skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
[skipButton setTitle:@"Skip" forState:UIControlStateNormal];
skipButton.frame = CGRectMake(0, 0, 150, 50);

[skipButton setCenter:CGPointMake(screenWidth - 30 - skipButton.frame.size.width, 100)];
[skipButton addTarget:self action:@selector(skipMovie) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:skipButton];

但是,我在 iPad1 上遇到了一些问题。如果我没有使用 setFullScreen 方法,即使我设置了 Rect (1024x768),电影也不会以全屏模式播放。但如果我设置这些,电影会以全屏模式播放,但我的@skipButton 不可见。

如果我使用:

    [self.view addSubview:playerViewController.view];

之后

[player play];

第一个问题发生了。即使没有 setFullScreen,该代码在 iPad2 中也能正常工作。

有没有人有什么想法?

[playerViewController.view bringSubviewToFront: skipButton]

没有做任何改变!!!

最佳答案

我想你可以用这个方法解决这个问题

[playerViewController.view bringSubviewToFront: skipButton];

请仅您的电影播放器​​加载电影调用函数

关于iphone - 如果使用全屏,则无法在 MoviePlayer 中看到按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15428535/

相关文章:

iphone - 使用数组填充 TableView 的正确方法?

iphone - 如何提高计步器算法的准确性?

iphone - 如何更改警报背景?我们可以改变它的立场吗?

ios - 如何解决malloc_error_break?

objective-c - 使用 Objective C 发送 POST 到 Web 服务器

ios - GCD 在状态改变后将 block 添加到串行队列中

iphone - 停止更新位置无法停止 iOS 中的位置更新?

ios - ScrollView 区域

ios - CollectionView 单元格在选中时移动

iphone - 如何创建五个带标签的 UIPickerView?以及如何在 iPhone 中为每个 UIPickerView 赋予不同的名称?