我在Xcode项目中有一个故事板,它变得太大了,导致我的电脑速度变慢。如何通过编程(或手动使用storyboarding)从当前故事板中的一个视图使用按钮前进到新故事板上的一个视图?
我对Xcode还不太熟悉,所以越简单越好。谢谢!
我在Xcode项目中有一个故事板,它变得太大了,导致我的电脑速度变慢。如何通过编程(或手动使用storyboarding)从当前故事板中的一个视图使用按钮前进到新故事板上的一个视图?
我对Xcode还不太熟悉,所以越简单越好。谢谢!
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)
在Sort中,您可以这样做:
presentViewController( UIStoryboard(name: "myStoryboardName", bundle: nil).instantiateViewControllerWithIdentifier("nextViewController") as UIViewController, animated: true, completion: nil)
不要忘记给您的下一个视图控制器添加ID。
有关更多信息,请参见此处。
Swift 3 解决方案:
present( UIStoryboard(name: "CreateOrder", bundle: nil).instantiateViewController(withIdentifier: "firstOrderViewController") as UIViewController, animated: true, completion: nil)