iPhone - How to transform an iPhone only app to universal app?

我的未来我决定 提交于 2019-11-30 23:19:16

"The first step is to select your target in Xcode, right-click and use the “Upgrade Current Target for iPad…” command. You will presented with a choice:

Select “One Universal application” and Xcode will do (some) of the hard work for us. The Apple guidelines warn against trying to manually migrate your target though to be honest it is hard to really see why. Also note that if your project has more than one target you can only run the upgrade task once. You will need to check all of your targets and adjust the build and Info.plist settings yourself."

http://useyourloaf.com/blog/2010/4/7/converting-to-a-universal-app-part-i.html

If you want to do it manually, first create a dummy/template Universal app, look at the differences between it and your app, and change your app to eliminate those differences. Among the steps:

Create iPad subdirectories.

Create suitable xibs for the iPad in that subdirectory. Interface Builder has a menu item to convert generic .xibs automatically.

Modify your info.plist (add the NSMainNibFile~ipad key) to use an iPad xib for the iPad main window. Also add appropriate icons, etc. to this plist.

Either create new subclasses for the iPad, or use modify your existing subclasses to check the UI paradigm and select the appropriate UI subelements & sizes in code. You can check in code using something like:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    ...
} else {
    ...  // iPhone stuff, etc.
}

If you created new classes, plug them into the iPad xibs as needed.

Modify all your Target settings to build for iPad and iPhone.

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