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

具体来说:

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


当前回答

通过阅读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. 您可能还必须更改您的约束条件。 这就是你所做的一切。

其他回答

你应该在苹果公司创建一个错误报告。你可以说它是我的(10167030)的副本,它自2011年9月以来一直开放。从我的角度来看,令人沮丧的事情是Xcode 3中就有这个功能……

我找到了一种解决方案:

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,则会出现以下对话框:

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

1 -创建“MainStoryboard_iPad.storyboard”;

2 -右键单击“MainStoryboard_iPhone.”故事板”和“打开作为->源代码”。所有复印件;

3-右键单击“MainStoryboard_iPad”。故事板”和“打开作为->源代码”。粘贴了一切。现在搜索和改变:

targetRuntime = " iOS。CocoaTouch" to targetRuntime="iOS.CocoaTouch.iPad" type = " com.apple.InterfaceBuilder3.CocoaTouch.Storyboard。" to type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.iPad.XIB"

4 -保存。现在重新打开,但是使用接口构建器。你只需要重新安排。

此方法也可用于.xib文件