【问题标题】:ObjC - Automatic View RotationObjC - 自动视图旋转
【发布时间】:2012-05-09 09:14:11
【问题描述】:

我和我的同学为 iPhone 编写了一个 Objective-c 程序。 但是我们有一个大问题:

我们的应用程序是在纵向模式下编码的,但应该在横向模式下(直接)显示 2 或 3 个视图。 我们在这些视图中激活了横向自动旋转,但是,如果我们现在打开其中一个视图,我们会再次获得纵向,并且只有在我们转动设备时才会变成横向。

(已经在我们的测试设备上,IOS模拟器没问题!)

有人可以帮帮我们吗?

【问题讨论】:

    标签: iphone autorotate


    【解决方案1】:

    唯一对我有用的是使用

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    

    在我的 ViewController 中并使用 presentModalViewController 呈现它。 这会强制 View 保持横向。

    【讨论】:

    • 谢谢! presentModalViewController 解决了我们的问题!现在我遇到了问题,我的横向视图中没有导航栏。我该怎么办?
    • 您可能必须将自己的 NavigationController 添加到以横向显示的视图中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多