简体   繁体   English

我们可以为 iPad 而不是 iPhone 显示 Settings.bundle 设置吗?

[英]Can we have Settings.bundle settings showing for iPad and not for iPhone?

Suppose I want to give permission to the user if he wants to rotate in iPad.假设如果用户想在 iPad 中旋转,我想给他权限。 There is no rotation scheme for iPhone so I need not provide this option of iPhone settings. iPhone 没有旋转方案,所以我不需要提供 iPhone 设置的这个选项。

To check if the device is iPad, you can do this:要检查设备是否为 iPad,您可以执行以下操作:

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

Similarly you can also do this:同样,您也可以这样做:

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
    //Setting for iPhone
}
else {
    //Setting for iPad
}
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;
}

In your project在你的项目中

Target->Summery-> Supported Interface Orientations in that it gives settings for interface orientations for iPhone and i pad separately Check it once Target->Summery-> Supported Interface Orientations 因为它分别为 iPhone 和 ipad 提供了界面方向设置 检查一次

Like below image像下图见下图

Settings.bundle file is common in program. Settings.bundle 文件在程序中很常见。 Its not like that if you an Universal application than you can have separate file for both iPhone & iPad.如果您是通用应用程序,那么您可以为 iPhone 和 iPad 拥有单独的文件,这不是这样。 It will be 1 common file.这将是 1 个公共文件。

You should give validations by checking If iPad Device than you can open orientations or if iPhone Device & lock the Orientation.您应该通过检查 iPad 设备是否可以打开方向或 iPhone 设备并锁定方向来进行验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM