我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
当前回答
There is a really simple solution for Xcode versions that support size classes (Tested in Xcode 7 which is the current version at the time of writing). Check the "use size classes" checkbox on a storyboard file (File Inspector), confirm that dialog that appears. Then uncheck that same checkbox - Xcode will ask you if you want to use this storyboard with an iPhone or iPad, and convert the screens in it appropriately. No need to directly edit the storyboard file. For both iPad and iPhone, just copy the same storyboard and configure one for iPad and one for iPhone using the described method.
在有人建议使用大小类之前——虽然很好,但对于重度定制的UI,比如游戏等,它们不太方便
其他回答
谢谢大家的回答。
我遵循了上述步骤,但当我在模拟器或iPad下运行应用程序时,它只使用iPhone故事板继续运行。
由于某种原因,当我将目标设备改为Universal而不是iPhone时,Xcode (v5.0)没有更新app-Info。plist文件来包含iPad故事板,所以我必须手动添加以下条目(使用Xcode中的plist编辑器):
主故事板文件基名(iPad) ==> MainStoryboard_iPad
这对我不太管用。我做了一些不同的事情。
为iPad版本创建一个新的故事板文件 在textwrangler(文本编辑器)中打开新文件和我想复制的文件 在这些xml标记之间将xml文本从旧文件复制到新文件 第一个标签<scenes> <!——内容视图控制器——> 粘贴在这里 结束标签</class> </classes> .结束标签
这对我很管用。我得到了一个新的布局,所有的插座都连接在一起,这为我节省了几个小时。
当我昨天遇到同样的问题时,我关注了这个帖子。我遵循的步骤
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”(我假设它匹配了一个硬编码的值)。实际上,更简单的是,从“分组”切换到“静态”,然后再切换回来似乎会重置默认颜色。
你应该在苹果公司创建一个错误报告。你可以说它是我的(10167030)的副本,它自2011年9月以来一直开放。从我的角度来看,令人沮丧的事情是Xcode 3中就有这个功能……