我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。

具体来说:

是否有类似的功能,还是只有手动的方式?


当前回答

使用XCode6大小类,您不再需要将故事板转换为iPad。 同一个Storyboard可以同时用于iPhone和iPad,使您不必同时更新两个文件。

生成的故事板与iOS7+兼容。

点击这里阅读更多信息: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html#//apple_ref/doc/uid/TP40014436-CH6-SW1

使用大小类使故事板或xib文件能够处理所有可用的屏幕大小。这使得应用程序的用户界面可以在任何iOS设备上工作。

其他回答

只是为了好玩,在XCode 5.1和iOS 7.1上,我还需要改变“toolVersion”和“systemVersion”的值:

toolsVersion="5023" systemVersion="13A603"

如果没有这个,新的故事板文件将无法编译

这对我不太管用。我做了一些不同的事情。

为iPad版本创建一个新的故事板文件 在textwrangler(文本编辑器)中打开新文件和我想复制的文件 在这些xml标记之间将xml文本从旧文件复制到新文件 第一个标签<scenes> <!——内容视图控制器——> 粘贴在这里 结束标签</class> </classes> .结束标签

这对我很管用。我得到了一个新的布局,所有的插座都连接在一起,这为我节省了几个小时。

我找到了一种解决方案:

Duplicate your iPhone-Storyboard and rename it MainStoryboard_iPad.storyboard Close Xcode and then open this file any text editor. Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad" Change the code in the MainStoryboard_iPad.storyboard from: <simulatedScreenMetrics key="destination" type="retina4"/> to <simulatedScreenMetrics key="destination"/> Now save everything and reopen Xcode. The iPad-Storyboard has the same contents as the iPhone-file but everyting could be disarranged.

这节省了我很多时间,希望这对你们有帮助

1. Create New Storyboard file with MainStoryboard_iPad.storyboard
2. Copy All the views from MainStoryboard and paste to MainStoryboard_iPad.storyboard

当我昨天遇到同样的问题时,我关注了这个帖子。我遵循的步骤

For Xcode 5.1, I had to do some cleanup of iPhone storyboard like missing reuseIdentifiers of Table cells, provide story board id for every controller, remove unused scenes. Copy MainStoryboard_iPhone.storyboard to MainStoryboard_iPad.storyboard. Using vi editor - changed targetRuntime="iOS.CocoaTouch" to targetRuntime="iOS.CocoaTouch.iPad" Change the code in the MainStoryboard_iPad.storyboard from: <simulatedScreenMetrics key="destination" type="retina4"/> to <simulatedScreenMetrics key="destination"/> Open the project in Xcode. Changed the Deployment devices to Universal - Chose the option of NOT copying the iPhone Storyboard. Xcode will default the Deployment Target to 7.1, took care of the deprecated functions. To fix the misplaced view error in iPad Storyboard - Changed the Frame Layout for Controllers giving errors.

就是这样。谢谢你的帮助。