第一:StoryBoard中ViewController与实体累的关联:只需要在 storyBoard对应的viewController: identity inspector的class属性即可,如下图:
第二,不同StoryBoard之间的跳转,首先是新建一个StoryBoard然后往里面加入ViewController 然后给这个ViewController一个storyBoardId即可,如下图:home就是这个viewController在此storyBoard的id
然后在需要跳转的地方:
@IBAction func goToSecondBord(sender: AnyObject) {//Second是对应storyBoard的名字
let vc=UIStoryboard(name: "Second", bundle: nil).instantiateViewControllerWithIdentifier("home")
self.navigationController?.pushViewController(vc, animated: true)
}
还有一种方法就是指定那个要跳转的ViewController为SecondBoard的入口Controller,但是这个方法有一定局限性,也就是说这个ViewController真是这个SencondBoard的入口才会合适,要不都是入口就乱了,具体操作如下图:选中is initial View Controller
调用代码:
@IBAction func gotoSecondViewController(sender: AnyObject) {
lable.text="可以去SencondView"
let viewController=UIStoryboard(name: "Second", bundle: nil).instantiateInitialViewController()
self.navigationController?.pushViewController(viewController!, animated: true)
//这中方法是把Second.board的UIViewController设置is insnal view cotroller 还有另种方法是设置id通过id找,然后跳转
// let viewController2=UIStoryboard(name: "Sencond", bundle: nil).instantiateViewControllerWithIdentifier("First")
// self.navigationController?.pushViewController(viewController2, animated: true)
}