When I run iPhone app on iPad the screen resolution is wrong. How to fix this?

I encountered with a strange problem. I develop an application which is targeting iPhone device family with Retina 3.5 and 4. All the time I used iPhone 5 simulator to test all the UI and functionality and everything was good but know I have to test push notifications. I have iPad 4 (model MD522ZP/A) as an iOS 6 device. When I run my app on it all the UI layout became wrong. The most weird problem is when I tried to check display resolution with this code:

NSLog(@"RESOLUTION = %@", NSStringFromCGSize([UIScreen mainScreen].bounds.size));

I got this : RESOLUTION = {320, 480} . But it is iPhone 3 resolution! Why iPad didn't use Retina 3.5/4 resolution ? And how can I fix it? I don't want to create separate xibs only for iPad testing but I want to test my app on it so that all the UI elements will fit on screen.

Hope for the help.


It's not wrong. It is doing exactly the right thing. All references to sizes are in points, not pixels. When you get the bounds, it will be 320x480 on all 3.5" screens whether they are retina or not. Try it on any 3.5" retina device. You will get the same log output.

The iPad does not emulate a 4" device when running an iPhone-only app. It will always be a 3.5" iPhone compatible mode.

So seeing 320x480 is the correct size to expect.

Think of it this way. A retina iPad will show an iPhone-only app like it is running on a 3.5" retina iPhone. A non-retina iPad will show an iPhone-only app like it is running on a 3.5" non-retina iPhone.

链接地址: http://www.djcxy.com/p/96690.html

上一篇: Delphi Android中的组件大小

下一篇: 当我在iPad上运行iPhone应用程序时,屏幕分辨率错误。 如何解决这个问题?