iPhone MPMoviePlayer 获取按钮视图

发布于 2024-08-11 04:37:05 字数 302 浏览 4 评论 0原文

谁能建议我如何获取包含“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

余罪 2024-08-18 04:37:05

您不能将其直接添加到 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.

维持三分热 2024-08-18 04:37:05

上面的答案实际上是不正确的:视图不是私有的,您可以向其添加视图。你只需要潜入足够深的地方就能找到它。

例如,在 iOS 5.1 中,您可以尝试这样的操作:

UIView *fullscreenOverlayView = [[[[[[[mpPlayer view] subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
[fullscreenOverlayView addSubview:ccButton];

这会将 CC 按钮添加到视图中,如果您为 CC 按钮的框架指定了正确的值,它将将该按钮插入到控制面板中,并且通过触摸控制面板隐藏/显示它。仅供参考:这是我使用的框架:

BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);

// all of these values are just based on measurement on screen
// to make sure that the CC button "seems" to be part of the player's control panel
if (isPortrait)
{
    return CGRectMake(222, 880, 40, 40);
}
else {
    return CGRectMake(350, 625, 40, 40);
}

注意:[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:

UIView *fullscreenOverlayView = [[[[[[[mpPlayer view] subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
[fullscreenOverlayView addSubview:ccButton];

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:

BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);

// all of these values are just based on measurement on screen
// to make sure that the CC button "seems" to be part of the player's control panel
if (isPortrait)
{
    return CGRectMake(222, 880, 40, 40);
}
else {
    return CGRectMake(350, 625, 40, 40);
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文