Testing different screen resolutions in Universal

2019-09-03 14:15发布

问题:

I notice when submitting a Universal app to the app store, there are various screen resolutions to support. I think iPhone/iPod: 320x460, 320x480, 640x960 and iPad 768x1024.

When I specify Universal app development in Xcode, the simulator has a resolution of 320x480. To view 768x1024 screen resolution, I can change the target setting to iPad, but how to test 320x460 and 640x960 resolutions?

My default solution is to target iPad, and manually hack my code, e.g.: SCREEN_WIDTH=640, SCREEN_HEIGHT=960; but surely there should be a setting on the simulator for this!?

In a related question, is there any way to get screen captures off the simulator (apart from command-shift-3 and cropping the resulting image)?

Thanks in advance.

回答1:

640x960 is an iPhone 4. You can simply select "iPhone 4" in the simulator device menu. You'll notice everything is twice as big (unless your computer has a small screen).

The iPhone 4 will still say its screen is 320x480 according to [[UIScreen mainScreen] applicationFrame].size see here for a discussion.

460x320 is the standard iPhone/iPod Touch screen minus the size of the status bar. You don't need to support it separately from 480x320.

Note: The "iPhone 4" option has been renamed "iPhone (Retina)" in recent simulator versions.

I don't think there is a better way to get screen captures off the simulator.