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

具体来说:

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


当前回答

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

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.

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

其他回答

进入目标摘要,将设备更改为通用, 然后向下设置iPad版本为任何你喜欢的故事板,包括一个复制和重命名一个如果你喜欢。

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文件

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

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.

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

这是另一种方式,但我能够做一个全选&复制在我的iPad故事板(~35个场景),并粘贴到我的iPhone故事板。场景大小自动调整。我只看到了两个问题,我必须替换UISplitViewController(因为它只是iPad),默认背景变成透明而不是灰色(仍在正确地修复这个问题,无需手动设置所有背景)。

编辑:在属性检查器中UITableView的默认背景似乎很奇怪。对于分组的表视图,我必须手动设置背景为“组表视图背景色”,对于非分组的表视图,我必须手动设置背景为“白色”。然后它被显示为“Default”(我假设它匹配了一个硬编码的值)。实际上,更简单的是,从“分组”切换到“静态”,然后再切换回来似乎会重置默认颜色。

如果你创建了一个通用项目,默认情况下会创建空的iPad storyboard,你只需要选择iPhone storyboard select all (Command+ a),复制(Command+C),然后粘贴到iPad storyboard上。在编译之前,请确保将入口点从空故事板移动到新复制的故事板。