I want to update my application to ios 6. so how to set the frame size comfortable both iphone 4 and iphone 5?
-
i have the same question – Jaspreet Singh Oct 10 '12 at 07:22
-
You can use auto layout while creating your app.Link for tutorial:http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2 – Nuzhat Zari Oct 10 '12 at 07:29
-
Please have a look at [this question](http://stackoverflow.com/questions/12527517/what-is-the-best-way-for-supporting-both-screen-resolution-of-iphone4-and-iphone). May be it will help. – Janak Nirmal Oct 10 '12 at 13:48
5 Answers
I can using Calculate the Screen size then to adjust the height of the view like using following method
+(CGFloat)heightOf:(CGFloat)heightValue{
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
//NSLog(@"applciation Frame height = %f",applicationFrame.size.height);
CGFloat heightRatio = (heightValue/480)*100;
CGFloat height = (applicationFrame.size.height * heightRatio)/100;
return height;
}
then I am using like as
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,[Height heightOf:385], 320, 220)];
and so. Thanks for your Replies

- 3,221
- 2
- 34
- 61
There is more than one way of handling the situation.
1> One of them is to use auto-resizing properly.
2>Another way is to use the new Auto Layout functionality, but then again this will only be supported for iOS 6.
3>You can create separate nib's for each view one for iphone 4 and iphone 5 and depending on which device it is running, you can switch the used .xib files.
Best way right now to go about is to use, auto resizing properly.
For more you can go through these

- 1
- 1

- 3,982
- 2
- 25
- 42
Following code check for the iPhone 5 and other device
#define IS_IPHONE ( [[[UIDevice currentDevice] model] isEqualToString:@"iPhone"] )
#define IS_IPOD ( [[[UIDevice currentDevice ] model] isEqualToString:@"iPod touch"] )
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f
#define IS_IPHONE_5 ( IS_IPHONE && IS_HEIGHT_GTE_568 )

- 1
- 1

- 16,776
- 8
- 50
- 72
AutoLayout did not work out so well for me. My app has several elements which need to be spaced out evenly.
A Quick fix solution (not good practice) is to assign coordinates individually upon the screen height check. (BTW that is a good tutorial. Shame Apple still haven't come up with anything substantial for IOS).
If You have several element on your screen, then I believe you'll have to re-place them individually
CGFloat height = [UIscreen mainScreen].bounds.size.height;
if(height==568.00){
self.imageName.frame = CGRectMake(x,y,width,height);
...
}
For a modal or floating screen which appears in the center of window, you could try this:
self.imgBadgeArea.frame = CGRectMake(self.view.bounds.size.width/2- self.imgBadgeArea.bounds.size.width/2, self.view.bounds.size.height/2 - self.imgBadgeArea.bounds.size.height/2, self.imgBadgeArea.bounds.size.width, self.imgBadgeArea.bounds.size.height);
Works for both 3.5 and 4 inches.

- 1,701
- 1
- 17
- 29