菜鸟教程小白 发表于 2022-12-13 14:28:10

ios - ViewController 的presentingViewController 设置错误?


                                            <p><p>如果 ViewControllerA 嵌入在 navigationController 中,并且 ViewControllerB 由 ViewControllerA 模态呈现。</p>

<p>当我打印 ViewControllerB 的presentingViewController 属性时,我发现presentingViewController 指向导航 Controller ,而不是ViewControllerA。</p>

<p>但我认为如果presentingViewController指向ViewControllerA更合理。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><blockquote>
<p>But i think if the presentingViewController point to ViewControllerA more reasonable</p>
</blockquote>

<p>问题是,你认为什么是合理的并不重要。你所看到的是它实际上是如何工作的。你的工作是接受和理解它,而不是不同意它。</p>

<p>导航 Controller 是呈现 ViewController ,因为它是 Root ViewController 。这是一个全屏演示,因此导航 Controller 是 ViewController ,其 View 被呈现的 ViewController 的 View 替换。</p>

<p>事实上,您发送到 ViewControllerA <em>的 <code>present</code> 被传递</em> 到包含导航 Controller 。您可以告诉 ViewControllerA <code>present</code> 只是为了方便。</p>

<p> ViewControllerA 被 Apple 称为“源” ViewController ,因为它是向其发送 <code>present</code> 的 ViewController ,但无法从与 ViewControllerB 的对话中得知这一点.</p>

<p>(您可能想阅读 <a href="http://www.apeth.com/iOSBook/ch19.html#_presented_view_controller" rel="noreferrer noopener nofollow">this section of my online book</a> ,从这句话开始,“呈现 ViewController ......不一定是您发送 <code>presentViewController:animated:completion:</code> 的 ViewController 。 "在我的书中,我将源 ViewController 称为<em>原始演示者</em>。)</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - ViewController 的presentingViewController 设置错误?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41114042/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41114042/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - ViewController 的presentingViewController 设置错误?