iOS 6 - 区分iPhone 5和其他设备?
问题描述:
随着今天iPhone 5和新款iPod的发布,我开始优化我的应用程序以利用新的额外屏幕空间。我已经到了应用程序不再“信箱”的地步了。我知道这是早,但有人知道我怎么能区分新的,较高的设备和旧的设备?iOS 6 - 区分iPhone 5和其他设备?
理想的情况下,这将是这样的:
if (device is iPhone 5 or taller iPod touch) {
do stuff that is ideal for the taller screen
} else {
do what I've been doing before for the smaller screen
}
谢谢!我希望其他人也在享受苹果今天宣布的内容!
答
- (BOOL)isTall
{
CGRect bounds = [[UIScreen mainScreen] bounds];
CGFloat height = bounds.size.height;
CGFloat scale = [[UIScreen mainScreen] scale];
return (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) && ((height * scale) >= 1136));
}
答
对于那些屏幕仍然会返回480而不是568,你需要在应用程序设置摘要选项卡中的新的大小添加新的启动映像。
答
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
// iPhone Classic
}
if(result.height == 568)
{
// iPhone 5
}
}
随着iOS6的依然NDA下,这样的问题可能没有得到回答的公共设置。我建议访问Apple开发者论坛。 –
噢,好的。由于通用汽车出局了,我不确定我是否还在继续,但谢谢。从现在开始,我会用这样的东西去开发论坛。 – mhbdr
@SlyRaskal - 这实际上不是iOS 6.0特有的,所以这是一个完美可行的问题。 –