首页 > 编程语言 > 详细

Swift不同storyboard之间的交互

时间:2015-11-20 10:29:49      阅读:250      评论:0      收藏:0      [点我收藏+]

如何实现多个Storyboard之间的切换

正如大家所知道的,Main-board是·程序运行的入口,如果找不到就会抛出异常,打开plist文件可以看到关于Main-board的描述,特别的制定了其base name为Main,那么我们如果有其他的Storyboard也需要在此注册一下,这样我们就可以使用name找到她,从而找到绑定在其上的所有元素。

正常的,我们实现一个storyboard上不同view的切换,常使用如下的方式:

let target = self.storyboard?.instantiateViewControllerWithIdentifier("target") as! TargetViewController
            presentViewController(target, animated: true, completion: nil)

 那么如果是不同的storyboard,我们所需要做的也只是找到那个需要的storyboard罢了,这时我们在plist中注册好的就起作用了

我们可以这样写:

let targetBoard:UIStoryboard = UIStoryboard(name: "Target", bundle: nil)

然后就跟上面一样了,是不是很简单与方便呢?

Swift不同storyboard之间的交互

原文:http://www.cnblogs.com/luckycandy/p/4979790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!