如何在播放视频之前设置当前 UIViewController 和 UINavigationBar 向下滑动的动画

发布于 2024-10-20 07:24:02 字数 352 浏览 1 评论 0原文

我在许多应用程序上看到过这种效果,包括 YouTube、Fandango、iPod 电影播放器​​、Netflix 应用程序,这样的例子不胜枚举……它们显示导航控制器 UI,您可以选择播放电影(从按钮),然后导航栏和视图控制器一起从屏幕上滑落,然后显示视频播放器。

我知道如何实现这种效果的唯一方法是,如果当前视图控制器(带有播放按钮)是通过presentModalViewController加载的,那么调用dismissModalViewControllerAnimated:YES就可以了。然而,上面并没有这样做,因为我可以清楚地看到当前视图控制器从右侧滑入,这是从导航控制器调用 PushViewController 产生的典型行为。

有什么想法吗?

I've seen this effect on numerous apps, including the YouTube, Fandango, the iPod movie player, Netflix app, the list goes on and on... They are displaying navigation controller UI, and you choose to play a movie (from a button on the current view controller), and then the nav bar as well as the view controller both slide down off the screen in unison, then the video player is revealed.

The only way I know how to acheive this effect is if the current view controller (with the play button) was loaded via presentModalViewController, then calling dismissModalViewControllerAnimated:YES will do the trick. However, the above are not doing this, as I can clearly see the current view controller sliding in from the right, which is typical behavior resulting from a call to pushViewController from the navigation controller.

Any ideas?

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

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

发布评论

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

评论(1

瑾夏年华 2024-10-27 07:24:02

对于初学者,您可能必须在最顶层的控制器上调用 [selfpresentModalViewController:moviePlayerViewControlleranimated:YES] 。在你的例子中,这将是导航控制器。例如

// initialize moviePlayerViewController
[self.navigationController
  presentModalViewController:moviePlayerViewController
                    animated:YES];

,但此解决方案仅淡入影片控制器,它不会将导航控制器的视图滑开。为此,您必须以所需的方式为视图设置动画。我推荐以下解决方案:

用于推送 UIViewController 的自定义动画

动画完成后完成后,您将显示电影播放器​​控制器。

For starters, you may have to call [self presentModalViewController:moviePlayerViewController animated:YES] on the top-most controller. In your case, that would be the navigation controller. E.g.

// initialize moviePlayerViewController
[self.navigationController
  presentModalViewController:moviePlayerViewController
                    animated:YES];

But this solution only fades the movie controller in, it does not slide the navigation controller's view out of the way. For that, you will have to animate the view in the desired way. I recommend the following solution:

Custom Animation for Pushing a UIViewController

After your animation is completed, you display the movie player controller.

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