如何从iPhone/iPad故事板迁移到通用故事板 [英] How to migrate from iPhone/iPad storyboards to universal storyboard
问题描述
我有一个用Xcode 5创建的项目.部署信息"设置显示设备:通用",但具有单独的iPhone和iPad设置以及相应的iPhone和iPad故事板.
I have a project created in Xcode 5. The "Deployment Info" settings says Devices: Universal but has separate iPhone and iPad settings and corresponding iPhone and iPad storyboards.
现在,我正在Xcode 6中开发 same 项目,我想使用一个通用情节提要,而不是两个情节提要.我只研究过iPhone故事板,还没有接触过iPad.是否可以抛弃iPad故事板并将现有的iPhone故事板转换为我的主要通用故事板?
Now I'm developing the same project in Xcode 6 and I want to use one universal storyboard instead of two storyboards. I have only worked on the iPhone storyboard and haven't touched the iPad one. Is it possible to ditch the iPad storyboard and convert the existing iPhone storyboard to be my main universal storyboard?
推荐答案
我改编了类似解决方案在下面创建此解决方案.
I adapted this tutorial and a similar solution by @tharkay to create this solution below.
- 将
Main_iPhone.storyboard
重命名为Main.storyboard
- 删除
Main_iPad.storyboard
- ***如果要使用iPad故事板而不是iPhone,请将
Main_iPad.storyboard
重命名为Main.storyboard
并删除Main_iPhone.storyboard
文件.然后,您需要转到文件检查器,右键单击情节提要,然后选择作为源代码打开".这将显示所有这些XML代码.将targetRuntime
从"iOS.CocoaTouch.iPad"
更改为"iOS.CocoaTouch"
- Rename
Main_iPhone.storyboard
toMain.storyboard
- Delete
Main_iPad.storyboard
- ***If you want to use the iPad storyboard instead of the iPhone, rename the
Main_iPad.storyboard
toMain.storyboard
and delete theMain_iPhone.storyboard
file. You will then need to go to the File Inspector and right-click your storyboard, then select "Open as Source Code". This will display all that XML code. ChangetargetRuntime
from"iOS.CocoaTouch.iPad"
to"iOS.CocoaTouch"
发件人:
targetRuntime="iOS.CocoaTouch.iPad"
收件人:
targetRuntime="iOS.CocoaTouch"
- 在项目文件的常规设置下,为iPhone和iPad选择
Main.storyboard
. - In the project file, under general settings, select
Main.storyboard
for both iPhone and iPad. - 在
Main.storyboard
的右侧面板上,选择Show the File inspector
图标. - On
Main.storyboard
, on the right-hand panel choose theShow the File inspector
icon. - 选中名为
Use Size classes
的框
- XCode将提示Xcode 5兼容性消息,请选择是".
- 编译并运行.
- 当然,您的所有视图都应该弄乱,并且您需要重做自动布局.
这篇关于如何从iPhone/iPad故事板迁移到通用故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!