Is detected iPhone 6 and 6+ height 568 points? - ios

I am maintaining an app that was developed before the release of iPhone 6 and iPhone 6 Plus. The developers of the app placed elements on screen using code. They detected screen heights placed views depending on the points of the screen height. As a maintainer of the app I need to make sure the app works well on the latest versions of the iPhone. The app seems to be working well on iPhone 6 and 6+ without modification and the screen height returned is 568. Will the app behave well on actual devices or is it simulator errors?

You might not get the app through the App Store. The problem is that the app is not actually "working well"; the iPhone 6 and iPhone 6 Plus are regarding it as an iPhone 5 app and are displaying it in "zoomed" mode. Apple might not accept that in a newly submitted build. If you give the project a Launch Screen, it will become a "native" iPhone 6 and iPhone 6 Plus app, and then you will see what the story really is.

Matt is right. I wrote a little method in my Utilities class that to determine screen sizes. The comments tell you what should be returned in the log for each device. The screen size and reported size are the same for all but iPhone 6 Plus.
+ (NSInteger)deviceType {
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
CGFloat deviceScale = [UIScreen mainScreen].scale;
LFDeviceType device = LFDeviceTypePhoneClassic;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
device = LFDeviceTypePhoneClassic; // Just in case it doesn't make it through the conditionals
// Classic has a resolution of 480 × 320
if( (screenSize.height == 480 || screenSize.width == 480) && deviceScale == 1.0f ) {
device = LFDeviceTypePhoneClassic;
// Retina has a resolution of 960 × 640
} else if( (screenSize.height == 480 || screenSize.width == 480) && deviceScale == 2.0f ) {
device = LFDeviceTypePhoneRetina3_5;
// Retina 4" has a resolution of 1136 x 640
} else if (screenSize.height == 568 || screenSize.width == 568 ) {
device = LFDeviceTypePhoneRetina4;
// iPhone 6 has a resolution of 1334 by 750
} else if (screenSize.height == 667 || screenSize.width == 667 ) {
device = LFDeviceTypePhone6;
// iPhone 6 Plus has an actual size of 2208 × 1242 and resolution of 1920 by 1080
// Reported size is 736 x 414 #3x
} else if (screenSize.height == 736 || screenSize.width == 736 ) {
device = LFDeviceTypePhone6Plus;
}
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
device = LFDeviceTypePadClassic; // Just in case it doesn't make it through the conditionals
if(deviceScale == 1.0f) {
device = LFDeviceTypePadClassic;
} else if (deviceScale == 2.0f) {
device = LFDeviceTypePadRetina;
}
}
//NSLog(#"The device is %# scale is %f and the height is %f and width is %f", device, deviceScale, screenSize.height, screenSize.width);
return device;
}

currently your app is working in zoomed mode, if you add splash screen for 6 and 6+ then your app will be in actual size, after include splash screen for 6 and 6+ you will get actual screen size.

Related

What should be the images size for bgs in iphone 6 and iphone 6+

what size of bg images should i use for iphone 6 and iphone 6+ apps.And what should be the extension for the same.
As I read some thread, i come to know we should use #2x images for iphone 6.
But #2x images also used by 4s devices; then how would you differentiate between the images used by 4s devices and iphone 6.
I use the following code to determine what device is running (it's a little bit quick and dirty but it does the trick)
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ){
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
if( screenHeight < screenWidth ){
screenHeight = screenWidth;
}
if( screenHeight > 480 && screenHeight < 667 ){
DLog(#"iPhone 5/5s");
} else if ( screenHeight > 480 && screenHeight < 736 ){
DLog(#"iPhone 6");
} else if ( screenHeight > 480 ){
DLog(#"iPhone 6 Plus");
} else {
DLog(#"iPhone 4/4s");
}
}
And the sizes are:
Yes.It uses same imageName#2x.png from iPhone4s to iphone 6.
but you can get the nativeBounds and nativeScale from screenbounds
Also, you can use this :
For example:
For example:
If you're displaying an photo in a UIImageView though, you can just create the largest size and let it either scale down to the iPhone 4s (using UIViewContentModeScaleAspectFill) or leave it as-is (using UIViewContentModeCenter).
For your Bg concern :
you can use autolayout constraints with the ImageView.
Also, you can Usethis

Auto Layout iphone 4 - 6plus

Since apple has now introduced the iPhone 6 + 6 plus. How would I make the image for different sizes of phones? For iPhone 4 and 5/5s/5c you would do
#define IS_568_SCREEN (fabs((double) [[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSLION)
if(IS_568_SCREEN) {
//Iphone 5/5s/5c
} else {
//iphone 4s }
But how would you do it for iPhone 4s to iPhone 6 plus? Also my auto layout isn't working very well. Im trying to change the size for all my objects dependent of the phone and using auto layout to place them correctly. However its not working out, I'm doing "height", "leading space to Container Margin", "Bottom Space To Bottom layout" and "Trailing space to container". As this will be a little hard and time consuming for all the objects sizes, can I use multiple storyboards? and what I mean by that is can I have one storyboard file for iPhone 6, then one for iPhone 6 plus etc. Or if not whats the proper way of doing auto layout on the interface builder?
Here's the answer to what I was looking for, nothing complicated :)
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenHeight = screenRect.size.height;
if (screenHeight == 480) {
// do iPhone 4s stuff
} else if (screenHeight == 568) {
// do iPhone 5, 5s, 5c stuff
} else if (screenHeight == 667) {
// do iPhone 6 stuff
} else if (screenHeight == 736) {
//do iPhone 6 plus stuff
}

xcode 6 is iphone 5 no longer 568 points in height?

So I'm trying to update my game to fit the iPhone 6 properly and i see now that when i run my game on the iPhone 5 simulator, everything is fitting as if it were an iPhone 4. I use if statements to determine the height of the device:
if ((int)[[UIScreen mainScreen] bounds].size.height == 568)
{
mylabel4.fontSize = 35;
mylabel4.position = CGPointMake(CGRectGetMidX(self.frame) -145, CGRectGetMidY(self.frame) -130);
} else {
mylabel4.fontSize = 35;
mylabel4.position = CGPointMake(CGRectGetMidX(self.frame) -110, CGRectGetMidY(self.frame) - 130);
}
And like i said when i run the iPhone 5 simulator, it runs the code in the 'else' bracket. Its like the iPhone 5 is no longer 568 points in height. This was working fine until i download Xcode 6? What's going on here?
The UIScreen bounds behavior has changed in iOS8. Previously it would always give you width and height of the screen in portrait (so 320 x 568 on the iPhone 5), but in iOS8 it will give you width and height with respect to whatever orientation you're in, i.e. in landscape you would get 568 x 320.
If you want to get the bounds in portrait (like before), use:
[UIScreen mainScreen].fixedCoordinateSpace.bounds.size
Just add launch images for the iPhone and the simulator will display the proper points. Weird bug.

How can I check what iOS device the user is using? [duplicate]

This question already has answers here:
Detect iOS device type
(5 answers)
Identify new iPhone model on xcode (5, 5c, 5s) [duplicate]
(6 answers)
Closed 9 years ago.
How can I find out what device a user is using? The code I currently use is:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if(screenBounds.size.height == 568){
NSLog(#"User is using an iPhone 5s, 5c, or 5");
}
else{
NSLog(#"User is using an iPhone 4s or earlier");
}
What other numbers could this return, and what device would it be? For example, I was hoping for something like this:
screenBounds.size.height == 568 would be an iPhone5/5s/5c
screenBounds.size.height == 480 would be an iPhone 4/5s
screenBounds.size.height > 570 would be an iPad
and so on. I'm going to be using this to change the nib file based on what device the user is using, so that I won't have to move every single button, image, label, or anything else with CGRectMake.
I'm not using auto layout because I would also like to have some more customization based on what device the user is using.
To check the kind of device:
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
// You are using iPad
return YES;
}
else if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomiPhone )
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if(screenBounds.size.height == 568){
NSLog(#"User is using an iPhone 5+");
} else{
NSLog(#"User is using an iPhone 4s-");
}
}

iPhone 5 Wrong Screen Height

I have developed an app on the 3.5 inch Screen and now I did a new Storyboard for the 4 inch screen and I do like follows to switch between storyboards on the appdelegate and I logged the screen height and it gives me 480.00000 check it:
NSLog(#"Checking Screen Size");
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
NSLog(#"On iPhone");
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
{ (diagonally measured)
NSLog(#"iPhone 4: %f", iOSDeviceScreenSize.height);
}
if (iOSDeviceScreenSize.height == 568)
{
NSLog(#"iPhone 5: %f", iOSDeviceScreenSize.height);
}
The NSLog gives me 480.0000 while my phone is iPhone 5
You need to add a "tall" startup image Default-568h#2x.png to the app to indicate that you support the new display size, otherwise you'll be run in compatibility mode (and not full screen).
You should add a new default image Default-568h#2x.png to the project.
It's very simple, just add Default-568h#2x.png which is Default image for iPhone 5 to the project.

Resources