Reputation: 27187
I am using XCode 4.5.1 and iOS Simulator (Retina 4 inch)
I have project that I made one yera ago. So now I want to migrate my project to new resolution.
My problem is next:
I integrate code into my project to detect which resolution I have.
CGRect screenBounds = [[UIScreen mainScreen] bounds];
But after I out value of screenBounds to NSLog I got width = 320 and height = 480, but I exprected to see 1136 × 640.
Have you got the same issues?
Upvotes: 0
Views: 759
Reputation: 159
To adapt your app to the new taller screen, the first thing you do is to change the launch image to: [email protected]. Its size should be 1136x640 (HxW). Yep, having the default image in the new screen size is the key to let your app take the whole of new iPhone 5's screen.
Also, you'll have to take a few more steps:
Make sure, your Xibs/Views use auto-layout to resize themselves. Use springs and struts to resize views. If this is not good enough for your app, design your xib/storyboard for one specific screen size and reposition programmatically for the other.
Upvotes: 1
Reputation: 2543
Are you sure you are using the 4inch simulator? [[UIScreen mainScreen] bounds]
will return the screen bounds in points, not pixels. So in the 4inch iPhone the CGRect
returned should be 320x568.
So if you call [[UIScreen mainScreen] bounds]
:
NOTE: If you didn't add the [email protected]
file, and the app runs letterboxed the method you used will return the iPhone 4 & 4S values.
TIP: To determine whether you are using an iPhone 5 or the rest, this code may come handy:
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
if( IS_IPHONE_5 )
{
// iPhone 5
}
else
{
// Other
}
Upvotes: 1