iPhone MPMoviePlayer 获取按钮视图
谁能建议我如何获取包含“MPMoviePlayer”中所有按钮的视图?
如果您不知道,至少知道如何获取 MPMoviePlayer 的主视图/窗口。
更新:我需要执行此操作以在控制器视图上添加一个按钮。它看起来像这样: 示例 http://img338.imageshack.us/img338/5184/poz.jpg
提前致谢!
Can anyone suggest me how to obtain the view that contains all buttons from 'MPMoviePlayer'?
If you don't know, at least how you obtain the main view/window of the MPMoviePlayer.
UPDATE: I need to do this to add a button on the controller view. It would look something like this:
Example http://img338.imageshack.us/img338/5184/poz.jpg
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能将其直接添加到 MPMoviePlayerController 的视图中——这是一个私有视图,无法访问。如果您想添加按钮,则需要在所有内容的顶部创建一个透明窗口并将按钮添加到其中。
Apple 的 MoviePlayer 示例展示了如何执行此操作。
You can't add it directly to the MPMoviePlayerController's view -- that's a private view and isn't accessible. If you want to add buttons, you need to create a transparent window over the top of everything and add the buttons to that.
Apple's MoviePlayer sample shows how to do this.
上面的答案实际上是不正确的:视图不是私有的,您可以向其添加视图。你只需要潜入足够深的地方就能找到它。
例如,在 iOS 5.1 中,您可以尝试这样的操作:
这会将 CC 按钮添加到视图中,如果您为 CC 按钮的框架指定了正确的值,它将将该按钮插入到控制面板中,并且通过触摸控制面板隐藏/显示它。仅供参考:这是我使用的框架:
注意:[mpPlayer view] 的子视图集对于不同的 iOS 版本是不同的,因此仅将此视为一种解决方法。无法保证这在 iOS 6 上有效,并且在 iOS 4.3 上会崩溃。
The above answer is actually incorrect: the view is not private, and you can add views to it. You just have to dive deep enough to find it.
For example, in iOS 5.1, you can try something like this:
This will add a CC button to the view, and if you specify the correct value for the frame of the CC button, it will insert the button to the control panel, and hide/show it with the control panel on touch. FYI: this is the frame I use:
NOTE: the set of subviews of [mpPlayer view] are different for different iOS versions, so consider this as a work around only. There's no guarantee that this will work on iOS 6, and will crash on iOS 4.3.