新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
新的iPhone 5屏幕有新的纵横比和新的分辨率(640 x 1136像素)。
开发新的应用程序或将现有应用程序转换到新的屏幕尺寸需要什么?
我们应该记住什么,使应用程序“通用”的旧显示器和新的宽屏纵横比?
当前回答
According to me the best way of dealing with such problems and avoiding couple of condition required for checking the the height of device, is using the relative frame for views or any UI element which you are adding to you view for example: if you are adding some UI element which you want should at the bottom of view or just above tab bar then you should take the y origin with respect to your view's height or with respect to tab bar (if present) and we have auto resizing property as well. I hope this will work for you
其他回答
唯一真正需要做的事情是在应用程序资源中添加一个名为“Default-568h@2x.png”的启动图像,在一般情况下(如果你足够幸运)应用程序将正常工作。
如果应用程序不处理触摸事件,那么确保键窗口有适当的大小。解决方法是设置适当的框架:
[window setFrame:[[UIScreen mainScreen] bounds]]
在迁移到iOS 6时,还有其他与屏幕大小无关的问题。详情请阅读iOS 6.0发布说明。
有时候(对于预storyboard应用程序),如果布局会有足够的不同,在viewController init中根据设备指定不同的xib是值得的(参见这个问题-你需要修改代码来处理iPhone 5),因为如果你需要不同的图形,再多的自动调整蒙版也不会起作用。
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
NSString *myNibName;
if ([MyDeviceInfoUtility isiPhone5]) myNibName = @"MyNibIP5";
else myNibName = @"MyNib";
if ((self = [super initWithNibName:myNibName bundle:nibBundleOrNil])) {
...
这对于针对旧iOS版本的应用程序非常有用。
通过xib .........很容易迁移iPhone5和iPhone4
UIViewController *viewController3;
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
UIViewController *viewController3 = [[[mainscreenview alloc] initWithNibName:@"iphone5screen" bundle:nil] autorelease];
}
else
{
UIViewController *viewController3 = [[[mainscreenview alloc] initWithNibName:@"iphone4screen" bundle:nil] autorelease];
}
而不是使用一组条件,您可以自动调整您的视图使用屏幕大小。
int h = [[UIScreen mainScreen] bounds].size.height;
int w = [[UIScreen mainScreen] bounds].size.width;
self.imageView.frame = CGRectMake(20, 80, (h-200), (w-100));
在我的情况下,我想要一个视图,填补在顶部的一些输入字段和底部的一些按钮之间的空间,所以固定的左上角和变量右下角基于屏幕大小。我的应用程序用相机拍摄的照片填充图像视图,所以我想要尽可能多的空间。
你可以添加以下代码:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 960) {
NSLog(@"iPhone 4 Resolution");
}
if(result.height == 1136) {
NSLog(@"iPhone 5 Resolution");
}
}
else{
NSLog(@"Standard Resolution");
}
}