How to make an iphone and iphone4-retina compatible app (done in cocos2d) easily adapted to ipad?

痞子三分冷 提交于 2019-12-06 09:58:42
sergio

As far as I know, there is no automatic adaptation of an iPhone app to iPad. You still should be able to create a universal app for both iPhone and iPad and then re-create your UI based on whether you are running on one device or the other.

Specifically, you could:

  1. Create an XCode project for a universal app (armv6 and armv7, targeting iPad and iPhone) and import there your existing project (source, resources, settings).

    1b. (you could modify your existing project, but this could be trickier to do correctly.)

  2. add icons and default images as per iPad guidelines in addition to those you have for iPhone;

As to the rest, you could follow a similar approach to the one highlighted here for Xibs:

  1. test for iPad:

    +(Bool)isIpad{ return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad); }

  2. translate image name before loading:

    +(NSString*)properImageFileName:(NSString*)imageName { if ([xxxx isIpad]) { return [NSString stringWithFormat:@"ipad_%@", imageName]; } else { return imageName; } }

Thus, if you are on iPhone, image names are not changed and will follow the iPhone convention for retina display; if you are on iPad, you change the name on the fly and use the right image. (of course, you can use the convention you prefer to identify iPad images).

This should make it pretty trivial, but keep in mind the size toll that having all the images in your universal app tolls.

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