2013-02-14 59 views
0

我正在将我的应用程序迁移到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 
} 

但似乎,我需要添加此代码为我的所有图像。有一种更简单的方法吗?意味着更通用的方式。

谢谢...

+0

是的,我向你确认这很简单。 – holex 2013-02-14 09:17:27

+0

可能重复的[如何检测iPhone 5(宽屏设备)?](http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices) – trojanfoe 2013-02-14 09:18:27

+0

可能的重复[如何开发或迁移iPhone 5屏幕分辨率的应用程序?](http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution) – 2013-02-14 09:26:58

回答

0

为UIImage类创建一个类别。 将此逻辑移至UIImage类。

现在使用您在该类别中创建的那个来更改现有的UIImage创建功能。

+0

您是否正在回答正确的问题? – trojanfoe 2013-02-14 09:35:50

+0

举个例子吧..拜托? – lakesh 2013-02-14 10:00:35

0

如果您是注册的Apple开发人员,则可以使用AutoLayout我推荐您可以从去年的WWDC中找到的教程。

+2

它不支持OS <6.0 – Apurv 2013-02-14 09:06:59

+0

好吧,然后AutoLayout不是一个选项。对不起 – JohannesRu 2013-02-14 09:10:42

+0

@Apurv - 在这一点上iOS6似乎有大约80%+采用 – 2013-02-14 09:21:31

0

检查写作这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 
} 
+0

如果设备方向是风景? – trojanfoe 2013-02-14 09:35:10

+0

也应该在横向模式下通知您有关iPhone 5的问题 – swapnil 2013-02-14 10:01:14

0

使用的是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]; 
    } 
} 
+0

这是为了支持方向并相应地设置视图和内容。 – Rahul 2013-02-14 09:54:44

+0

我已经有一个应用程序的ios5如何将其迁移到iOS6? – lakesh 2013-02-14 10:00:10

0
  1. 首先,你必须创建一个尺寸为640 x 1136和视网膜品质启动图像启动图像。
  2. 然后将图像命名为[email protected],并将其设置为iphone应用程序中的启动图像。
  3. 然后你将不得不设置自动调整大小掩码。
  4. 创建您想要与iPhone 5屏幕分辨率兼容的所有必需图像。
  5. 在您的iPhone 5中运行您的应用程序,一切都应按需要工作。