新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
当前回答
使用视图的自动布局功能。它将自动调整到所有分辨率。
为控制器名称后缀为~iphone或~ipad的控制器创建两个xib。在编译时,Xcode将根据设备取正确的xib。
使用大小类,如果你想为iPhone和iPad创建一个单独的xib,如果视图足够简单,可以移植到iPhone和iPad。
其他回答
在单例类中尝试下面的方法:
-(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";
}
在横屏模式下,使用568检查边界将失败。iPhone 5只在纵向模式下启动,但如果你想支持旋转,那么iPhone 5的“check”也需要处理这种情况。
这是一个宏,它处理方向状态:
#define IS_IPHONE_5 (CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size, CGSizeMake(640, 1136)))
'preferredMode'调用的使用来自我几个小时前读的另一篇文章,所以我没有想到这个想法。
使用xCode 5,在项目>General上选择“迁移到资产目录”。
然后使用“Show in finder”找到你的启动图像,你可以模拟编辑它为640x1136,然后拖到资产目录,如下图所示。
确保iOS7和iOS6 R4部分都有一个640x1136的图像。下次你启动应用程序时,黑条将消失,你的应用程序将使用4英寸的屏幕
I never faced such an issue with any device as I've had one codebase for all, without any hardcoded values. What I do is to have the maximum sized image as resource instead of one for each device. For example, I would have one for retina display and show it as aspect fit so it will be views as is on every device. Coming to deciding the frame of button, for instance, at run time. For this I use the % value of the patent view, example , if I want the width to be half of parent view take 50 % of parent and same applies for height and center.
有了这个,我甚至不需要xib。
你可以使用自动布局功能,使用iPhone 5屏幕分辨率创建设计,它适用于4英寸和3.5英寸设备,但在这种情况下,你应该有足够的布局管理器知识。