新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
当前回答
在横屏模式下,使用568检查边界将失败。iPhone 5只在纵向模式下启动,但如果你想支持旋转,那么iPhone 5的“check”也需要处理这种情况。
这是一个宏,它处理方向状态:
#define IS_IPHONE_5 (CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size, CGSizeMake(640, 1136)))
'preferredMode'调用的使用来自我几个小时前读的另一篇文章,所以我没有想到这个想法。
其他回答
Download and install latest version of Xcode. Set a Launch Screen File for your app (in the general tab of your target settings). This is how you get to use the full size of any screen, including iPad split view sizes in iOS 9. Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly, or used Auto Layout. If you didn't, adjust your view layouts, preferably with Auto Layout. If there is something you have to do for the larger screens specifically, then it looks like you have to check height of [[UIScreen mainScreen] bounds] as there seems to be no specific API for that. As of iOS 8 there are also size classes that abstract screen sizes into regular or compact vertically and horizontally and are recommended way to adapt your UI.
在单例类中尝试下面的方法:
-(NSString *)typeOfDevice
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
return @"Iphone";
}
if(result.height == 568)
{
return @"Iphone 5";
}
}
else{
return @"Ipad";;
}
return @"Iphone";
}
你可以使用这个定义来计算你是否使用基于屏幕大小的iPhone 5:
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
然后使用简单的if语句:
if (IS_IPHONE_5) {
// What ever changes
}
在横屏模式下,使用568检查边界将失败。iPhone 5只在纵向模式下启动,但如果你想支持旋转,那么iPhone 5的“check”也需要处理这种情况。
这是一个宏,它处理方向状态:
#define IS_IPHONE_5 (CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size, CGSizeMake(640, 1136)))
'preferredMode'调用的使用来自我几个小时前读的另一篇文章,所以我没有想到这个想法。
我添加了新的默认启动图像,(在检查其他几个SE答案…)确保我的故事板都自动大小和子视图,但视网膜4英寸仍然是信箱。
然后我注意到我的信息plist有一个行项目“启动图像”设置为“Default.png”,因此我删除了它,神奇的字母盒不再出现。希望这能让别人免受我所经历的疯狂。