首页 文章

一个故事板中iPhone和iPad的不同方向

提问于
浏览
3

我正在开发一个iOS应用程序,它实际上是现有Web应用程序的包装器 . 它增加了一些只能通过这种方式实现的附加功能 .

我使用大小类和布局约束完成了应用程序的设计 . 我在iPhone和iPad上都使用了一个故事板 . 问题是,我希望iPhone应用程序只能使用纵向模式,而iPad可能只使用横向模式(有针对iPhone和iPad优化的不同Web应用程序) .

是否可以仅使用一个故事板来完成此操作,或者我是否需要使用两个故事板(一个用于iPhone,设置为仅纵向;一个用于iPad,仅设置为风景);因此重复我的设计?

3 回答

  • 2

    打开info.plist文件作为代码并粘贴此代码:

    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    

    对我来说效果很好!

  • 2

    是的,你可以在iOS8中做到这一点有一个非常令人兴奋的功能,名为 Adaptive Layout ,同样的故事板现在可以用于运行iOS 8的iPad和iPhone . 没有必要让每个设备的故事板保持彼此同步 .

    这是非常好的tutorial,它会帮助你 .

  • -1

    只需将其粘贴在您的App代表中:

    - (NSUInteger)application:(UIApplication *)application
    supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
            return UIInterfaceOrientationMaskLandscape;
        else
            return UIInterfaceOrientationMaskPortrait;
    }
    

相关问题