gpt4 book ai didi

xcode - 使用 Swift 在 Storyboard之间切换

转载 作者:IT王子 更新时间:2023-10-29 05:06:58 27 4
gpt4 key购买 nike

我的 Storyboard在我的 Xcode 项目中变得太大并且拖慢了我的计算机。如何以编程方式(或手动使用 Storyboard)使用按钮从当前 Storyboard中的一个 View 前进到新 Storyboard上的 View ?

Xcode 半新所以越简单越好。谢谢!

最佳答案

您可以通过这种方式编程:

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 .

关于xcode - 使用 Swift 在 Storyboard之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29505916/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com