gpt4 book ai didi

ios - Storyboard instantiateViewControllerWithIdentifier 不设置 IBOutlets

转载 作者:IT王子 更新时间:2023-10-29 07:42:35 26 4
gpt4 key购买 nike

我正在使用 Storyboard instantiateViewControllerWithIdentifier: 并且我注意到我连接的所有 IBOutlets 仍然为零。但是,我连接的 IBActions 可以正常工作。 View 和 Controller 是链接的(即 controller.view 不是 nil),如果我显示 View ,它会显示我所期望的内容。

我错过了什么?

这是我的设置:

  1. 我在 Storyboard中定义了一个 View Controller 。我给了它一个标识符,它与调用 instantiateViewControllerWithIdentifier:
  2. 时使用的标识符相同
  3. 我已经通过点击 View Controller (就在第一响应者下方)设置了 View 的所有者,并在身份检查器下将自定义类设置为与我想要将 View 连接到的类同名。<
  4. 然后我打开辅助编辑器,并控制拖动 UI 元素以创建 IBOutletsIBActions

最佳答案

View 似乎只有在第一次访问后才正确初始化。调用时问题消失

[self presentViewController:vc animated:NO completion:nil];

或者更简单的说

[vc view];

关于ios - Storyboard instantiateViewControllerWithIdentifier 不设置 IBOutlets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12523198/

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