iphone 5 retina display - ios

I am completely new to iOS i am developing an app which is compatible with iPhone 5 also i want to apply background image to view my question is that should i need two different images of both sizes????
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
// iPhone 4S background view
}
if(result.height == 568)
{
// iPhone background image
}
}

Say you've background.png for app background, now to support retina devices you should have an exact double size of background.png that will be added as background#2x.png in your project folder. The selection of normal or retina image will be handled by iOS itself based on which device you've!
Okay, now for iPhone 5 device which height is not equivalent to iPhone 3G, 4, 4S you need background.png of 640(width)*1136(height), as iPhone 5 only supports retina images. For that you need to include background-568h#2x.png to differentiate it from other files.
An example of splash screen,
Default.png --- Normal devices, iPhone 3G
Default#2x.png --- Retina devices, > iPhone 3G
Default-568h#2x.png --- Retina devices only, > iPhone 4S
It will select specific splash screen automatically!

Related

Why in XCode 7 iPhone 6 plus simulator's [UIScreen mainScreen] size and scale return different value with real devce?

After upgrading to xcode 7, I found a strange problem. When I call [[UIScreen mainScreen] scale] on iPhone6+ simulator, it returns 3.0, but it returns 2.0 on iPhone 6+ real device.
Is this a bug or it will also return 3.0 on iPhone 6s+ real device? since I haven't got the real iPhone 6s+, cannot test it yet.
PS. If I don't set "App Icons and Launch Images"->"Launch Screen File", [[UIScreen mainScreen] bounds].size will return 320x480, but if set "Launch Screen File", it will return 414x736, is there any documents for this problem?
Take a look at my note https://github.com/onmyway133/blog/issues/59
See this for a whole list of devices and their scale factors https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
The iPhone 6 and 6+ introduced display mode https://www.cnet.com/how-to/explaining-display-zoom-on-iphone-6-and-6-plus/
You can see that currently the iPhone 6+, 6s+, 7+ phones have scale factor of 2.88 in zoomed mode, and 2.6 in standard mode
You can also see that in zoomed mode, iPhone 6 has the same logical size as the iPhone 5

iOS - App Rejected Because Of Guideline 2.10 - Resolution For iPad - How to Fix?

My iPhone only app has been rejected for the following reason provided by Apple:
We noticed that your app did not run at iPhone resolution when reviewed on iPad running iOS 9, which is a violation of the App Store Review Guidelines.
I now understand that the iPad has its own iPhone simulator that you can run iPhone apps on. After initial debugging, I noticed that, when testing on the iPad Air (iOS 9.0), my iPhone 5 storyboard is being used in its own iPhone simulator.
This is how it looks (correctly) on the iPhone 5:
http://i.stack.imgur.com/SMHyx.png
And this is how it looks (incorrectly) on the iPad:
http://i.stack.imgur.com/2PHG4.png
Since the iPad is using my iPhone 5 storyboard, why isn't it scaling everything correctly? How do I fix this?
*****EDIT*****
I have discovered that I made a mistake when debugging and the iPad's iPhone simulator has a display height of 480, which is the size of an iPhone 4. My code below was causing my iPhone 6+ storyboard to be shown:
CGSize result = [[UIScreen mainScreen] bounds].size;
//get the right storyboard for the device.
if(result.height == 568)
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone5" bundle:nil];
NSLog(#"IPHONE 5 STORYBOARD!");
}
else if(result.height == 667)
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone6" bundle:nil];
NSLog(#"IPHONE 6 STORYBOARD!");
}
else //iPhone 6+
{
storyBoard = [UIStoryboard storyboardWithName:#"iPhone6Plus" bundle:nil];
NSLog(#"IPHONE 6+ STORYBOARD!");
}
However, I thought I made my app for only iPhone 5 and up by setting it to iOS 8 and up, meaning that I don't have an iPhone 4 storyboard. How do I solve this issue?
It is not possible otherwise to restrict your app on a per device basis. Since your app is iOS 8 and up, you will have to support iPhone 4S's resolution. Since iPhone 4S is getting iOS 9 too, you will have to support it in the near future too.
iPad always presents a view size equal to iPhone 4S or lower when you run iPhone app in iPad. So try to change your app in such a way that your app should work properly with iPhone 4 simulator or device.
You solve the problem by either supporting the iPad properly (have an iPhone + iPad application), or by supplying a storyboard for 3.5 inch - alternatively, using the 4 inch storyboard, using layout constraints properly, and perhaps adjusting some properties.
The obvious change for picking the right storyboard is to change: if (height <= 568) .. else if (height <= 667) ... else ... Your code says that everything that isn't 568 or 667 pixels high is a 6+, which as you can see is nonsense.
You could also just support the iPad and use the 6+ storyboard for the iPad. Again, using layout constraints properly.

Getting the screen size of iPhone 6 and iPhone 6 plus

I have an application which is compatible with iPhone4 upto iPhone 6. For displaying the UI on multiple devices I am using:
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
and depending on the height and width returned, I am identifying the iPhone type and displaying a relevant image. The problem is when I run this code on the iPhone 6 or iPhone 6 Plus simulator it is still returning 568px as the screen height, the same as the iPhone 5.
How do I get the screen height of iPhone 6 and iPhone 6 Plus please?
Please create a XIB file named as LaunchScreen.xib. and set this as your launch screen file under "App icons and launch images" tab.
Or you can simply add launch images for iPhone 6 and 6 Plus. It will resolve your issue.

iPhone 6, iOS 8.1 reports 320x568 points screen on Device, but 375x667 on Simulator

I'm using iOS 8.1, Xcode 6.1 on both Device and Simulator.
NSLog(#"SCREEN (%i x %i) SCALE: %i", (int)[UIScreen mainScreen].bounds.size.width, (int)[UIScreen mainScreen].bounds.size.height, (int)[UIScreen mainScreen].scale);
Result on Device: SCREEN (320 x 568) SCALE: 2
Result on Simulator: SCREEN (375 x 667) SCALE: 2
I have used Asset Catalog, Default image for iPhone 6 (750x1334px) is displayed correctly on Simulator, but again iPhone 5 one (640x1136px) is displayed on Device.
PS. iPhpne 6 Plus works perfectly on both Device and Simulator reporting SCREEN (414 x 736) SCALE: 3, which is correct.
My app should use the exact images and layouts for all devices by design.
What am I doing wrong?
May be when you made setup for your new iPhone you chose ZOOM mode for device?
Note that there are two ways to ZOOM on the iPhone:
1) The one relevant to this issue is at: "Settings - Display & Brightness - View"
and set to "Standard" to turn off the Zoom.
2) Another one at: "Settings - General - Accessibility - Zoom" is not relevant to this issue.

iPad 3rd generation can not display retina image

I have develop one universal app. I have four type images
iphone - simple.png
iphone retina - simple#2x.png
ipad - simple#3x.png
ipad retina - simple#3x#2x.png
When i try to run the application, it works fine into ipad (non retina) but it gives black screen (no images) into ipad retina.
Here, put code of function which give me related name for iphone & ipad.
#define SHImageString(str, ext) ({ UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? ([NSString stringWithFormat:#"%#.%#", (str), (ext)]) : ([NSString stringWithFormat:#"%##3x.%#", (str), (ext)]); })
Thanks in advance.
It should be like this:
iphone-simple.png
iphone retina - simple#2x.png
ipad - simple_iPad.png
ipad retina - simple_iPad#2x.png
In your code (or XIB) you only use the files without the #2x. If the app is run on a retina display it will automatically use the #2x version. I've used this many many time, works perfect.

Resources