我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
当前回答
对于 Xcode10
复制Main.storyboard 然后将文件重新命名为Main_iPad。storyboard和main_iphone。storyboard 在.plist中设置适当的名称
4.只需选择适当的.storyboard进行配置
其他回答
我找到了一种解决方案:
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.
这节省了我很多时间,希望这对你们有帮助
只是为了好玩,在XCode 5.1和iOS 7.1上,我还需要改变“toolVersion”和“systemVersion”的值:
toolsVersion="5023" systemVersion="13A603"
如果没有这个,新的故事板文件将无法编译
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,比如游戏等,它们不太方便
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文件
对于那些可能对我的观点有异议的人,我想简短地提醒一下:
我的问题:
故事板内容很好地复制到我添加的新板文件中。但是,它不会将更改转移到我配备的iPad上。注意到我必须为构建目标切换指定的故事板(见图),让更改显示出来。
如果我有点,我会张贴一个图像,但设置位于:
左侧源菜单上的项目导航器,项目的根目标(中心窗格)一般选项卡,(第二子标题)部署信息,选择iPad按钮选项卡。
从那里,在“主界面”下选择你的故事板。
谢谢你的帖子,我希望这能帮助你解决问题。