我的Xcode项目中的故事板太大,导致计算机速度变慢。如何以编程方式(或手动使用故事板)从当前故事板中的某个视图中使用按钮前进到新故事板上的视图?
Xcode的半新功能越简单越好。谢谢!
答案 0 :(得分:42)
你可以用这种方式编程:
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。
有关更多信息,请参阅THIS。
答案 1 :(得分:37)
答案 2 :(得分:5)
Swift 3解决方案:
present( UIStoryboard(name: "CreateOrder", bundle: nil).instantiateViewController(withIdentifier: "firstOrderViewController") as UIViewController, animated: true, completion: nil)