如何让 `-[MPMoviePlayerController backgroundView]` 立即显示?

发布于 2024-10-28 23:15:12 字数 298 浏览 4 评论 0原文

目前我的 -[MPMoviePlayerController backgroundView] 直到电影加载足够后才会出现。因此,我放置在那里的 UIActivityIndi​​catorView 不会立即出现。这让我发疯。找到的唯一解决方案是将重复的指示器视图放置在背景视图和-[MPMoviePlayerController view]之间。但这看起来不正常,而且绝对是视图层次结构黑客,不能保证正常工作。如果背景视图立即显示,一切都会神奇地进行。

如何在电影加载之前立即制作背景视图?

Currently my -[MPMoviePlayerController backgroundView] does not appear until movie loaded enough. So UIActivityIndicatorView which I placed on there does not appear immediately. This drives me crazy. The only solution have been found is placing duplicated indicator-view somewhere between background-view and -[MPMoviePlayerController view]. But this does not look regular, and definitely a view hierarchy hack which is not guaranteed to work properly. If the background-view shows immediately, all will work magically.

How can I make the background-view immediately before movie loaded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

风筝在阴天搁浅。 2024-11-04 23:15:12

不要使用backgroundView,而是使用moviecontroller本身的视图...

以下步骤(假设您的MPMovieControllerPlayer实例名为moviePlayerController并且您的UIActivityIndi​​catorView实例称为 activityIndi​​catorView)

  • 将您的 UIActivityIndi​​catorView 添加到 MPMoviePlayerController 视图之上(例如 [moviePlayerController.view addSubview:activityIndi​​xatorView];

  • 开始为活动指示器设置动画

  • 注册 MPMoviePlayerLoadStateDidChangeNotification

  • 在上述通知的处理程序中,注意moviePlayerController.loadState & MPMovieLoadStatePlayable == MPMovieLoadStatePlayable

  • 如果满足上述条件,则隐藏您的活动指示器

Do not use the backgroundView but the view of the moviecontroller itself...

Following steps (assuming your MPMovieControllerPlayer instance is called moviePlayerController and your UIActivityIndicatorView instance is called activityIndicatorView)

  • Add your UIActivityIndicatorView on top of the MPMoviePlayerController view (e.g. [moviePlayerController.view addSubview:activityIndixatorView];)

  • Start animating the activity indicator

  • Register for MPMoviePlayerLoadStateDidChangeNotification

  • Within the handler of the above notification, watch out for moviePlayerController.loadState & MPMovieLoadStatePlayable == MPMovieLoadStatePlayable

  • If the above condition is matched, hide your activity indicator

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