在开发app时,我们通常会使用storyboard来提高开发效率。下面介绍的是多个storyboard之间controller的跳转。
首先新建三个storyboard分件,分别为Main.storyboard,Home.storyboard,Message.storyboard目录结构如图。
在Main.storyboard 中添加一个tabbarcontroller,用于管理三个子模块,分别为post、message、home
home和message模块分别在home.storyboard和message.storyboard中。
main.storyboard中通过添加storyboard reference指向其他storyboard中的controller。如图选中storyboard reference控件拖两个到main.storyboard中。然后分别设置home、message的navigation controller的root controller为storyboard reference控件。
选中storyboard reference 控件设置其Storyboard和referenced id
其中referenced id为目标controller的storyboard id。如果不写则为storyboard文件中initial controller。
重构一个storyboard中的controller到新的storyboard文件中方法。
选中需要重构的controllers,点击editor -> Refactor to storyboard。
源码地址:http://git.oschina.net/lcjilt/storyboard