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

此生再无相见时 提交于 2019-12-18 06:54:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/18046285/when-i-run-iphone-app-on-ipad-the-screen-resolution-is-wrong-how-to-fix-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!