如何在播放视频之前设置当前 UIViewController 和 UINavigationBar 向下滑动的动画
我在许多应用程序上看到过这种效果,包括 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于初学者,您可能必须在最顶层的控制器上调用
[selfpresentModalViewController:moviePlayerViewControlleranimated: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.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.