将我的应用程序迁移到iPhone 5分辨率
我正在将我的应用程序迁移到iPhone应用程序到iPhone 5的分辨率。我已经在计算器这说明其他问题看出:将我的应用程序迁移到iPhone 5分辨率
例子:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}
但似乎,我需要添加此代码为我的所有图像。有一种更简单的方法吗?意味着更通用的方式。
谢谢...
如果您是注册的Apple开发人员,则可以使用AutoLayout我推荐您可以从去年的WWDC中找到的教程。
它不支持OS Apurv 2013-02-14 09:06:59
好吧,然后AutoLayout不是一个选项。对不起 – JohannesRu 2013-02-14 09:10:42
@Apurv - 在这一点上iOS6似乎有大约80%+采用 – 2013-02-14 09:21:31
检查写作这prefix.h
文件
#define IPHONE5 (fabs((double)[ [ UIScreen mainScreen ] bounds ].size.height - (double)568) < DBL_EPSILON)
,只要你想检查,只要检查
if (IPHONE 5) {
// Code for iPhone 5 Device
enter code here
} else if (!IPHONE5) {
// Code for 3.5 inch (iphone 4 nad less)
enter code here
}
使用的是iOS 6为基数SDK构建的应用程序,并使用自动布局功能制作可以适用于所有类型屏幕的屏幕。你需要Xcode 4.5才能做到这一点。添加一个名为[email protected]
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
//[self ArrangeControllsFor_Protrate];
[self performSelector:@selector(ArrangeControllsFor_Protrate) withObject:Nil afterDelay:0.005f];
return YES;
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
[self performSelector:@selector(ArrangeControllsFor_LandScape) withObject:Nil afterDelay:0.005f];
return YES;
break;
}
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
switch (toInterfaceOrientation){
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
[self performSelector:@selector(ArrangeControllsFor_Protrate) withObject:Nil afterDelay:0.005f];
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
[self performSelector:@selector(ArrangeControllsFor_LandScape) withObject:Nil afterDelay:0.005f];
break;
}
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate{
return YES;
}
-(void)ArrangeControllsFor_Protrate{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self.view setBounds:CGRectMake(0, 0, 320,568)];
[self.view setFrame:CGRectMake(0, 0, 320, 568)];
}
-(void)ArrangeControllsFor_LandScape{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self.view setBounds:CGRectMake(0, 0, 568, 320)];
[self.view setFrame:CGRectMake(0, 0, 568, 320)];
}
- (void)viewWillAppear:(BOOL)animated{
UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if(UIInterfaceOrientationIsPortrait(statusBarOrientation))
{
[self ArrangeControllsFor_Protrate];
}
else
{
[self ArrangeControllsFor_LandScape];
}
}
- 首先,你必须创建一个尺寸为640 x 1136和视网膜品质启动图像启动图像。
- 然后将图像命名为[email protected],并将其设置为iphone应用程序中的启动图像。
- 然后你将不得不设置自动调整大小掩码。
- 创建您想要与iPhone 5屏幕分辨率兼容的所有必需图像。
- 在您的iPhone 5中运行您的应用程序,一切都应按需要工作。
是的,我向你确认这很简单。 – holex 2013-02-14 09:17:27
可能重复的[如何检测iPhone 5(宽屏设备)?](http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices) – trojanfoe 2013-02-14 09:18:27
可能的重复[如何开发或迁移iPhone 5屏幕分辨率的应用程序?](http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution) – 2013-02-14 09:26:58