【问题标题】:Can we have Settings.bundle settings showing for iPad and not for iPhone?我们可以为 iPad 而不是 iPhone 显示 Settings.bundle 设置吗?
【发布时间】:2014-03-27 05:34:04
【问题描述】:

假设我想授予用户在 iPad 中旋转的权限。 iPhone 没有旋转方案,所以我不需要提供这个 iPhone 设置选项。

【问题讨论】:

  • 您可以检查设备,如果设备是 iPad,shouldAutoRotate 将返回true。您也可以制作一个 baseController 来处理这种情况。

标签: ios settings.bundle


【解决方案1】:

要检查设备是否为 iPad,您可以这样做:

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    //Setting for iPad
}
else {
    //Setting for iPhone
}

同样你也可以这样做:

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
    //Setting for iPhone
}
else {
    //Setting for iPad
}

【讨论】:

    【解决方案2】:
    BOOL isiPad;
    //Declare global Bool value
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    // The device is an iPad 
    // Enable rotation here
     isiPad=YES;
    }
    else {
    // The device is an iPhone or iPod touch.
    // disable rotation here
    }
    
    
    //Set your rotation methods here 
    -(BOOL)shouldAutorotate
    {
    
            return isiPad;
    }
    

    【讨论】:

      【解决方案3】:

      在你的项目中

      Target->Summery-> 支持的界面方向 因为它分别提供了 iPhone 和 i pad 的界面方向设置 检查一次

      如下图

      【讨论】:

        【解决方案4】:

        Settings.bundle 文件在程序中很常见。如果您是通用应用程序,则不是这样,您可以为 iPhone 和 iPad 拥有单独的文件。它将是 1 个通用文件。

        您应该通过检查如果 iPad 设备比您可以打开方向或如果 iPhone 设备并锁定方向来进行验证。

        【讨论】:

        • @user3427687 disable 表示您只能为 iPhone 设置特定方向掩码。
        猜你喜欢
        • 2014-05-11
        • 1970-01-01
        • 1970-01-01
        • 2011-01-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-10
        相关资源
        最近更新 更多