【问题标题】:Sliding UIViewcontroller to left/right向左/向右滑动 UIViewcontroller
【发布时间】:2013-02-17 10:18:36
【问题描述】:

我正在使用:

ViewController = [[ViewControllerClass alloc] initWithNibName:@"ViewControllerClass" bundle:[NSBundle mainBundle]];
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:frontViewController animated:YES completion:nil];

我正在尝试将UIViewController 向左滑动,但我不确定为什么它不起作用。我什至在尝试:

UIModalTransitionStyleCrossDissolve

这不起作用。请建议我如何实现向左/向右滑动UIViewController

【问题讨论】:

    标签: iphone ipad uiviewcontroller


    【解决方案1】:

    当您调用presentViewController:animated:completion: 时,这会在当前视图控制器之上显示一个模态视图控制器。默认转换是从底部向上滑动视图控制器。 UIModalTransitionStyle 枚举定义了四种可能的转换。

    模态转换不支持左/右转换。

    左/右转换是使用UINavigationController 及其pushViewController:animated: 和各种pop... 方法时的标准转换。

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

    要关闭您执行的顶视图控制器:

    [self.navigationController popViewControllerAnimated:YES];
    

    【讨论】:

    • 谢谢 maddy,我现在应该做些什么改变?
    • 如果你想要一个模态转换,那么选择 4 种转换类型之一。接受你没有左/右作为选择之一的事实。如果您对模态演示的使用不是您真正需要/想要的,那么使用UINavigationController 并使用pushViewController:animated: 添加额外的视图控制器。
    猜你喜欢
    • 1970-01-01
    • 2011-03-29
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    • 2015-07-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多