简体   繁体   English

如何在视图控制器中执行从左到右的转换,反之亦然

[英]How to do left to right transition and vice versa in viewcontrollers

In my iphone application, i am using storyboard layout to display my views. 在我的iPhone应用程序中,我使用情节提要布局显示我的视图。 for my requirement , i am navigating my storyboard viewcontrollers with the help of this code: 根据我的要求,我正在以下代码的帮助下导航情节提要视图控制器:

 NextViewController *vc = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:NULL]
                                            instantiateViewControllerWithIdentifier:@"NextView"];

        [self presentViewController:vc animated:NO completion:nil];

Note that seques are not available in my code. 请注意,我的代码中没有定序符。 This current approach perfectly navigating the views from bottom to top. 当前的方法完美地将视图从底部导航到顶部。 But i want to navigate from left to right/ viceversa. 但是我想从左到右/反之亦然。 please provide any solution to resolve my problem. 请提供任何解决方案来解决我的问题。

Use a push transition. 使用推送转换。 Push requires that you have a UINavigationController . 推送要求您具有UINavigationController

[self.navigationController pushViewController:vc animated:YES];

If you are using Storyboard, then create a UINavigationController and Ctrl-drag from it to your view controller and set it as the rootViewController . 如果使用的是Storyboard,则创建一个UINavigationController Ctrl-dragCtrl-drag到视图控制器,并将其设置为rootViewController This will create the default-looking navigation bar at the top of your app. 这将在应用程序顶部创建外观默认的导航栏。

To "go back" programmatically from a pushed view controller, use: 要以编程方式从推送的视图控制器中“返回”,请使用:

[self.navigationController popViewControllerAnimated:YES];

I suggest you read about modal and push transitions, because the differences between them are not just "bottom-to-top" and "right-to-left". 我建议您阅读有关模态推式过渡的信息,因为它们之间的差异不仅是“从下到上”和“从右到左”。 Pushing is for seeing more detail, while presenting a view controller modally is for starting a different task. 推送用于查看更多细节,而模态呈现视图控制器用于启动其他任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM