【问题标题】:Xcode 4 component orientation problemXcode 4 组件方向问题
【发布时间】:2011-05-13 08:07:50
【问题描述】:

我在我的项目中使用 xCode 4,它应该可以在 iPad 和 iPhone 上运行。所以,我创建了基于通用 Windows 的应用程序。我希望我的应用程序开始进入横向模式,所以我添加了以下内容: 在方法中:

shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

我设置interfaceOrientation == UIInterfaceOrientationLandscapeRight 并将密钥添加到application.plist: Initial Interface Orientation 并将其设置为横向(右主页按钮)。

现在,应用程序确实以横向模式启动,但是其中的每个组件(按钮、标签)保持旋转 90 度(逆时针)。 当我加载 xib 时,窗口方向设置为纵向并且下拉菜单被禁用。 有人知道我做错了什么吗?

【问题讨论】:

    标签: iphone xcode sdk orientation landscape


    【解决方案1】:

    shouldAutorotateToInterfaceOrientation 不是要求您设置变量(即使您这样做也无法读取结果),而是询问指定的方向是否可以接受。所以你想要:

    - (BOOL)shouldAutorotateToInterfaceOrientation:
                                        (UIInterfaceOrientation)interfaceOrientation
    {
        if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES;
        return NO;
    }
    
    /* or: return interfaceOrientation == UIInterfaceOrientationLandscapeRight; */
    

    XIB 是一个单独的问题; Interface Builder 及其在 Xcode 4 中的替换部件都无法看到您在代码中所做的事情,因此他们不应该拒绝让您在横向模式下进行设计。但是,要设置方向的是与相关 UIViewController 的视图成员相关联的视图,而不是窗口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      相关资源
      最近更新 更多