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

具体来说:

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


当前回答

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

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

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

其他回答

通过阅读stackoverflow上的许多线程,我发现解决方案是-

1.复制你的iPhone-Storyboard并重命名为MainStoryboard_iPad.storyboard

2.右击故事板->“打开为”->“源代码”。

3.搜索targetRuntime="iOS "。CocoaTouch,然后把它改成targetRuntime=" ios。CocoaTouch。ipad "

5.搜索<simulatedScreenMetrics key="destination" type="retina4"/>并将其更改为<simulatedScreenMetrics key="destination"/>

4.现在保存所有内容,右键单击MainStoryboard_iPad。storyboard " open as " ->"IOS storyboard " 5. 您可能还必须更改您的约束条件。 这就是你所做的一切。

对于 Xcode10

复制Main.storyboard 然后将文件重新命名为Main_iPad。storyboard和main_iphone。storyboard 在.plist中设置适当的名称

4.只需选择适当的.storyboard进行配置

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

toolsVersion="5023" systemVersion="13A603"

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

我找到了一种解决方案:

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.

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

这个功能现在是内置的。例如,如果将“部署信息->设备”中的项目设置从iPhone更改为Universal,则会出现以下对话框: