我有一个故事板,它在我的Xcode项目中变得太大,导致我的计算机变慢。如何使用按钮以编程方式(或手动使用故事板)从当前故事板中的一个视图前进到新故事板上的视图?
Xcode是半新的,所以越简单越好。谢谢!
发布于 2015-04-08 12:41:35
您可以通过以下方式进行编程:
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。
发布于 2016-11-24 14:49:40
0行代码
使用接口生成器

按住
UIButton拖动到该故事板Control
UIViewController引用ID
完整的图片

发布于 2016-10-14 09:57:36
Swift 3解决方案:
present( UIStoryboard(name: "CreateOrder", bundle: nil).instantiateViewController(withIdentifier: "firstOrderViewController") as UIViewController, animated: true, completion: nil)https://stackoverflow.com/questions/29505916
复制相似问题