gpt4 book ai didi

swift - 从主 Storyboard显示 View Controller

转载 作者:行者123 更新时间:2023-11-28 06:00:40 24 4
gpt4 key购买 nike

我的一个 Swift 文件中有一个 case,它运行以下方法:

     case .editProfile:
vc = PoiDetailViewController()
self.navigationController?.popViewController(vc,animated: true)

当我运行代码时它似乎不起作用。

View Controller 位于主 Storyboard上,我希望在调用此案例时显示 PoiDetailViewController

最佳答案

如果我理解正确,您应该能够通过代码中的 present 实现您正在寻找的内容。像这样:

  case .editProfile:
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyBoard.instantiateViewController(withIdentifier: "PoiDetailViewController") // or whatever identifier you have given it
self.present(vc, animated: true, completion: nil)

这应该可行,但是,请确保您在身份检查器中为您的 View Controller 设置了 Storyboard ID。

无需转场。

要设置 Storyboard ID,请单击您要使用的 View Controller (在本例中为 PoiDetailViewController),然后单击身份检查器图标并在要求的位置设置 Storyboard ID。我附上了一张图片,以便您可以看到它需要去哪里(在标记为“ Storyboard ID”的字段中)

Identity inspector

希望对您有所帮助。

关于swift - 从主 Storyboard显示 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49876102/

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