全屏模式下的 MPMoviePlayer 叠加层 (iPad)
我想在全屏播放时在视频播放器上添加一个按钮。我在我的视频播放器上创建了一个叠加层,它在 iPhone 上运行得很好。我在 iPad 上尝试了同样的操作,但按钮从未出现。
这是我的代码:
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1){
UIWindow * moviePlayerWindow = [windows objectAtIndex:1];
NSArray * subviews = [moviePlayerWindow subviews];
UIView * videoView = [subviews objectAtIndex:0];
[videoView addSubview:myButton];
}
看起来 ipad 没有为全屏模式创建 UIWindow。
有人知道我该怎么做吗?
谢谢!
I want to add a button on my video player when it is playing in fullscreen. I created an Overlay on my videoplayer and it's working very well on an iPhone. I tryed to same thing on a iPad, but the button never appear.
Here's my code :
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1){
UIWindow * moviePlayerWindow = [windows objectAtIndex:1];
NSArray * subviews = [moviePlayerWindow subviews];
UIView * videoView = [subviews objectAtIndex:0];
[videoView addSubview:myButton];
}
It seams like the ipad dosen't create a UIWindow for the fullscreen mode.
Anyone have any idea on how I could do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几周前我找到了这个问题的解决方案:
看来这个方法在 iPad 上不起作用(我还没有检查过 iPhone SDK 4>),所以为了解决这个问题,你可以执行以下操作。
添加视频并设置为全屏后,您可以将控件直接添加到 UIWindow(例如 [[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubView:myView]),然后它们将显示在视频视频的顶部。
我发现的唯一问题是它们不遵守视图的方向规则,并且我必须在视图的 willRotateToInterfaceOrientation 方法中手动编写旋转代码。
I found a solution to this problem a few weeks ago:
It seems this method does not work on the iPad (I havent checked iPhone SDK 4>) so in order to get round it you can do the following.
After adding your video and setting to fullscreen you can add your controls directly to the UIWindow (e.g. [[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubView:myView]), they will then appear on top of your video video.
The only problem I have found with this is that they dont obey the orientation rules of the view and I have manually had to program the rotation code in the willRotateToInterfaceOrientation method of the view.
@tigermain 的解决方案有效。
但是添加到窗口的视图不遵循方向。
方向的解决方案是使用 NSNotificationCenter、UIApplicationDidChangeStatusBarOrientationNotification。
The solution from @tigermain works.
But the views added to the window do not follow the orientation.
Solution for the orientation is to use NSNotificationCenter, UIApplicationDidChangeStatusBarOrientationNotification.