Set*_*eth 25 xcode storyboard swift
我有一个故事板在我的Xcode项目中变得太大并且减慢了我的计算机速度.如何以编程方式(或手动使用故事板)从当前故事板中的一个视图中使用按钮进入新故事板上的视图?
使用Xcode的半新版本越简单越好.谢谢!
Dha*_*esh 44
你可以用这种方式编程:
Swift 3+
let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ViewControllerID") as UIViewController
present(vc, animated: true, completion: nil)
年长
let storyboard = UIStoryboard(name: "myStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("nextViewController") as UIViewController
presentViewController(vc, animated: true, completion: nil) 
在排序中你可以这样做:
presentViewController( UIStoryboard(name: "myStoryboardName", bundle: nil).instantiateViewControllerWithIdentifier("nextViewController") as UIViewController, animated: true, completion: nil)
并且不要忘记给你的nextViewController提供ID.
有关更多信息,请参阅此处.
Swi*_*ect 37

UIButton到该故事板参考
UIViewController
Swift 3解决方案:
present( UIStoryboard(name: "CreateOrder", bundle: nil).instantiateViewController(withIdentifier: "firstOrderViewController") as UIViewController, animated: true, completion: nil)