gpt4 book ai didi

ios - UIStoryboard Reference 和 Root View Controller

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:48 24 4
gpt4 key购买 nike

我有一个“主” Storyboard ,在这个 Storyboard 中我有一个 Storyboard 引用实体链接到另一个 Storyboard “登录”。我注意到,当我尝试使用以下内容访问当前屏幕上的 View 时:

[[[[UIApplication sharedApplication]delegate]window]rootViewController]

它返回“主” Storyboard上的 View ,但如果我尝试在此 View 上推送 UIAlertController,我会收到以下错误:

Warning: Attempt to present <UIAlertController: 0x1839a000> on <ViewController: 0x17633ad0> whose view is not in the window hierarchy!

有什么原因我不能将此 View 推到顶部,如果不是,我如何从“登录” Storyboard 中获取当前显示的实际 uiviewcontroller?

最佳答案

如果您从 viewDidload 中呈现 UIAlertController 那么它可能会像这样发生,因为当时加载 View 时它不在窗口层次结构中,直到它完全加载。

第二件事你必须在最顶层的 View Controller 上呈现 UIAlertController,比如,

 [self presentViewController......];

不适用于 Windows rootViewController。所以,这取决于你是怎么做的。

关于ios - UIStoryboard Reference 和 Root View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39327574/

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