iPhone 5 app running on iPad reports height 480 - ipad

NSLog( #"height %f", [[UIScreen mainScreen] bounds].size.height) reports 568 on iPhone 5 (iOS 7.1.2), but 480 on iPad Retina (iOS 8.0.2). How can I get it to report (and run!) as 568 on iPad (iPhone emulation)? Thanks for helping a newbie.
Edit: It comes up in 2x on iPad; can I force it to 1x?

Was a duplicate, found answers: Can't be done, no.

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.

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.

UIScreen.mainScreen is the same size on all devices [duplicate]

This question already has an answer here:
App not sized properly iOS 8 iPhone simulator
(1 answer)
Closed 8 years ago.
I have a weird issue which suddenly appeared. The problem is that my app seems to be scaling my views, when changing device from iPhone 6 to iPhone 6 Plus for instance. So if I have a title with a certain font size the same title with take up the same amount of space on the iPhone 6 Plus screen when all I want is for the size to be the same and just appear smaller on the larger device. Do anyone know how this happened and how to fix this?
I noticed by running:
NSLog(#"%f", [UIScreen mainScreen].bounds.size.width);
NSLog(#"%f", [UIScreen mainScreen].bounds.size.height);
That his generates the same output on all simulator devices:
320
568
I would expect it to be something different on the larger devices. Does this have anything to do with it?
Did you add launch images for the iPhone 6 and 6 Plus devices? Otherwise it will run scaled in these resolutions (and the [[UIScreen mainScreen] bounds] call will return the bounds as if running in a 4-inch device).
Just add a new default png photo with 1136 height.
[[UIScreen mainScreen] bounds].size
will return new height of 4-inch screen.
It is not a bug. You could review session 214 from WWDC 2014 for more info: "View Controller Advancements in iOS 8"
Quote from the presentation:
UIScreen is now interface oriented:
[UIScreen bounds] now interface-oriented
[UIScreen applicationFrame] now interface-oriented
Status bar frame notifications are interface-oriented
Keyboard frame notifications are interface-oriented
You could still work around to get the different values. Here is the code:
+ (CGRect)screenBoundsFixedToPortraitOrientation {
UIScreen *screen = [UIScreen mainScreen];
if ([screen respondsToSelector:#selector(fixedCoordinateSpace)]) {
return [screen.coordinateSpace convertRect:screen.bounds toCoordinateSpace:screen.fixedCoordinateSpace];
}
return screen.bounds;
}

iphone 5 retina display

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!

Resources