ios 处理 iPad Mini 屏幕尺寸
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13036745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dealing with iPad Mini screen size
提问by MCKapur
The new iPad Mini has a 7.9 inch screen size. Does it have a retina display? Will it automatically scale existing xibs and storyboards or do we have to create two versions of each?
新款 iPad Mini 的屏幕尺寸为 7.9 英寸。它有视网膜显示屏吗?它会自动缩放现有的 xib 和故事板还是我们必须为每个创建两个版本?
Do we deal with it similar to the way we deal with the iPhone 5?
我们处理它的方式是否与处理 iPhone 5 的方式类似?
How would I create a definition or a condition to see if the device is running iPad Mini?
我将如何创建定义或条件来查看设备是否正在运行 iPad Mini?
采纳答案by rmaddy
If your app works on an iPad 1 or an iPad 2 it will work as-is on the new iPad mini. There is no retina display on the mini. From an app's perspective it's identical to the iPad 2.
如果您的应用程序在 iPad 1 或 iPad 2 上运行,它将在新的 iPad mini 上正常运行。mini 上没有视网膜显示屏。从应用程序的角度来看,它与 iPad 2 相同。
Edit: It was asked how to determine when an app is running on an iPad mini. There is no API check for this. The screen size doesn't help. UI_USER_INTERFACE_IDIOM()
doesn't help. Until someone actually has one, there is no way to know if the UIScreenMode pixelAspectRatio
is any different (probably it's the same as the iPad 2).
编辑:有人询问如何确定应用程序何时在 iPad mini 上运行。没有针对此的 API 检查。屏幕大小没有帮助。UI_USER_INTERFACE_IDIOM()
没有帮助。在有人真正拥有一台之前,无法知道它是否UIScreenMode pixelAspectRatio
有任何不同(可能与 iPad 2 相同)。
This leaves only one possibility - to get the machine
from uname()
and hardcode a check against this value. This is never a desired approach. And as of this writing, we don't know what the value will be. Perhaps iPad5,xassuming the 4th gen iPad is iPad4,x.
这仅剩下一种可能性 - 获取machine
fromuname()
并针对此值进行硬编码检查。这绝不是一种理想的方法。在撰写本文时,我们不知道其价值是多少。也许iPad5,x假设第 4 代 iPad 是iPad4,x。
Edit: So far I've seen a report that the iPad mini returns iPad2,5 (yes, that's a two comma five) as well as iPad2,6 and iPad2,7 for the machine name.
编辑:到目前为止,我看到一个报告说 iPad mini 返回 iPad2,5(是的,这是一个两个逗号 5)以及 iPad2,6 和 iPad2,7 作为机器名称。
回答by Uday Kiran Nelluri
Apps will work fine. But if you have some very small UI elements. you might want to revisit them due to the reduction in screen size.
应用程序将正常工作。但是如果你有一些非常小的 UI 元素。由于屏幕尺寸的减小,您可能想要重新访问它们。
回答by Beltalowda
Build apps for iPad 2 resolution. The new iPad Mini is non-retina with a resolution of 1024x768 which means Apps that already worked on an iPad 1 or iPad 2 automatically work on iPad Mini.
为 iPad 2 分辨率构建应用程序。新的 iPad Mini 是非视网膜的,分辨率为 1024x768,这意味着已经在 iPad 1 或 iPad 2 上运行的应用程序会自动在 iPad Mini 上运行。
回答by Mick MacCallum
I think Phil Schiller (Apple's Senior Vice President) said it best in press eventunveiling the iPad Mini (approximately 53:00 into the keynote)
我认为菲尔席勒(Apple 的高级副总裁)在发布 iPad Mini 的新闻发布会上说得最好(大约 53:00 进入主题演讲)
What screen size do we pick and why? And the team worked really hard thinking about this. We want an iPad that is capable of running all that amazing software written for iPad without the developers having to do any work...
我们选择什么屏幕尺寸,为什么?考虑到这一点,团队非常努力地工作。我们希望 iPad 能够运行所有为 iPad 编写的出色软件,而无需开发人员做任何工作......
He then goes on to say:
然后他继续说:
...And the pixels are even easier to remember because they're exactly the same. The original iPad and the iPad 2 are 1024 by 768 and the new iPad Mini is 1024 by 768. That means all of the software created for iPad works on the iPad Mini unchanged.
...而且像素更容易记住,因为它们完全相同。最初的 iPad 和 iPad 2 是 1024 x 768,而新的 iPad Mini 是 1024 x 768。这意味着所有为 iPad 创建的软件都可以在 iPad Mini 上正常运行。
So, in summary and to answer your question, no the iPad Mini does not have a Retina display, and you don't have to do any additional work. The iPad Mini will utilize the storyboard or xib you have already created for iPads.
因此,总而言之,为了回答您的问题,iPad Mini 没有 Retina 显示屏,您无需做任何额外的工作。iPad Mini 将利用您已经为 iPad 创建的故事板或 xib。
Then as far as detection goes, I can't find anything to prove this yet (because they haven't been released yet) but I'd be willing to bet that the following will output "iPad Mini".
然后就检测而言,我还找不到任何东西来证明这一点(因为它们尚未发布)但我愿意打赌以下将输出“iPad Mini”。
NSLog(@"%@",[[UIDevice currentDevice] model]);
EDIT:
编辑:
NSLog(@"\nMachine ID: %@\nModel: %@\nLocalized Model: %@",machineName(),[[UIDevice currentDevice] model],[[UIDevice currentDevice] localizedModel]);
NSString *machineName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
}
On my 16GB iPad Mini (Wifi only) this returns:
在我的 16GB iPad Mini(仅限 Wifi)上,返回:
Machine ID: iPad2,5
Model: iPad
Localized Model: iPad
机器 ID:iPad2,5
型号:iPad
本地化型号:iPad
回答by johnnelm9r
If the iPad Mini and the non-retina iPad's are going to be the same screen size regardless, couldn't you use something like what is used to determine whether the device screen is an iPhone 5 or iPhone 4:
如果 iPad Mini 和非视网膜 iPad 的屏幕尺寸无论如何都相同,那么您不能使用类似于用于确定设备屏幕是 iPhone 5 还是 iPhone 4 的东西:
#define IS_WIDESCREEN5 ( [ [ UIScreen mainScreen ] bounds ].size.height == 568 )
#define IS_WIDESCREEN4 ( [ [ UIScreen mainScreen ] bounds ].size.height == 480 )
So for iPad Mini, and non-retina iPad's, do:
因此,对于 iPad Mini 和非视网膜 iPad,请执行以下操作:
#define IS_PAD ( [ [ UIScreen mainScreen ] bounds ].size.height == 512 )
and for retina iPad's do:
对于 Retina iPad,请执行以下操作:
#define IS_RETINA_PAD ( [ [ UIScreen mainScreen ] bounds ].size.height == 1024 )
This should differentiate the two types of screens and bypass the need to pinpoint the exact model for scale purposes. The alternate method would be to use auto-layout, however I have a better feeling of control without it.
这应该区分两种类型的屏幕,并绕过为缩放目的精确定位精确模型的需要。另一种方法是使用自动布局,但是没有它我有更好的控制感。
I hope this helps with the second part of your question. Good luck :)
我希望这对您问题的第二部分有所帮助。祝你好运 :)
回答by Sanjeev sharma
回答by iDev
You dont have to do anything different. It should automatically work as mentioned by apple. The resolution is still the same as iPad.
你不必做任何不同的事情。它应该像苹果提到的那样自动工作。分辨率仍与 iPad 相同。
回答by CalZone
Images for ipad mini will be same for ipad 1 and 2. But it is recommended you use @2x images for retina screen too. Because, once your app is on app store, you cannot stop people from downloading it on ipad with retina display.
ipad mini 的图像对于 ipad 1 和 2 是相同的。但建议您对视网膜屏幕也使用 @2x 图像。因为,一旦您的应用在应用商店上架,您就无法阻止人们在带有视网膜显示屏的 iPad 上下载它。
So at this point of time, you'll have to make images for both retina and non retina.
所以在这个时候,你必须为视网膜和非视网膜制作图像。
Programatically, separate xib files are NOT required for ipad retina display. Just keep [email protected] too for all image assets.
以编程方式,ipad 视网膜显示不需要单独的 xib 文件。只需为所有图像资产保留 [email protected] 。
回答by Slyv
To detect iPad Mini (any model) i'm using this code (tested on iOS 10.x):
要检测 iPad Mini(任何型号),我正在使用此代码(在 iOS 10.x 上测试):
- (BOOL)isIPadMini {
return [[UIDevice currentDevice].name hasPrefix:@"iPad Mini"];
}