从屏幕右侧打开另一个视图控制器视图
我想从屏幕右侧打开一个视图控制器。
那就是在做
[自我呈现ModalViewController:pvc动画:是];
我希望另一个视图控制器的视图看起来好像是从屏幕右侧滑动的,而不是看起来好像是从屏幕底部来的:)
我怎样才能实现这一点。请帮忙:)
I want to open a viewcontroller from right side of the screen.
That is on doing
[self presentModalViewController:pvc animated:YES];
I want the another viewcontroller's view to appear as if its sliding from the right of the screen instead of appearing as if it is coming from the bottom of the screen :)
How can I achieve that. Please help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的是 UINavigationController。
在您的应用程序委托中,您将在
applicationDidFinishLoading
中看到如下所示的一行:将该行更改为:
Now 而不是
[selfpresentModalViewController:pcvanimated:YES];
可以做:这是一个给出“从右侧滑入”动画的控件。 Plus 允许您更好地控制应用程序内的视图堆栈和导航。这是控制应用程序中导航的最佳方式。
ps: navController 现在会泄漏 - 就像我的示例中的这样,这样你就可以看到我在做什么。您需要在应用程序委托的 .h 中将 navController 设为 iVar,以便可以在
dealloc
中释放它。如果您像现在一样释放它,那么您将无法向其发送消息。What you are looking for is a UINavigationController.
In your app delegate you will have a line that looks like this in
applicationDidFinishLoading
:Change that line to these:
Now instead of
[self presentModalViewController:pcv animated:YES];
you can do:This is the control which gives the "slide in from the right" animation. Plus allows you to better control a view stack and navigation within an app. Its the best way to control navigation in your app.
ps: that navController will leak now - its just like this in my example so you can see what I'm doing. You'll want to make the navController an iVar in the .h of your app delegate so you can release it in
dealloc
. If you release it like it is now then you won't be able to send messages to it.查看 UINavigationController - 类参考 。这使您可以组织一个从侧面滑入的层次结构。或者您可以使用 UIView 动画块< /a>.找出最适合您的应用程序的内容。如果您需要从侧面推送多个内容(例如类别),请使用 UINavigationController。如果您只有一个简单的视图,想要从侧面进入并离开,您将需要使用 UIView 动画或其他动画方法。 UIView 动画将如下所示:
Look into UINavigationController - Class Reference. This lets you organize a hierarchy that will slide in from the side. Or you can play with the UIView animation blocks. Figure out whats best for your app. If you have several things you will be pushing from the side, like categories, use UINavigationController. If you just have a simple view you want to come in from the side and leave, you'll want to use the UIView animation or other animation methods. The UIView animation will look like this: