ios - ViewController 的presentingViewController 设置错误?

标签 ios uiviewcontroller

如果 ViewControllerA 嵌入在 navigationController 中,并且 ViewControllerB 由 ViewControllerA 以模态方式呈现。

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

但我认为如果presentingViewController指向ViewControllerA更合理。

最佳答案

But i think if the presentingViewController point to ViewControllerA more reasonable

问题是,你认为合理的并不重要。您所看到的就是它实际上是如何工作的。你的工作是接受并理解它,而不是不同意它。

导航 Controller 是呈现 View Controller ,因为它是 Root View Controller 。这是全屏演示,因此导航 Controller 是 View Controller ,其 View 将被呈现的 View Controller 的 View 替换。

事实上,发送到 View Controller A 的present会被传递到包含的导航 Controller 。您可以告诉 View Controller A present 只是为了方便。

View Controller A 被 Apple 称为“源” View Controller ,因为它是 present 发送到的 View Controller ,但无法从与 View Controller B 的对话中了解到这一点.

(您可能想要阅读 this section of my online book ,从这句话开始,“呈现 View Controller ...不一定是您向其发送 presentViewController:animated:completion: 的 View Controller 。 “在我的书中,我将源 View Controller 称为原始呈现器。)

关于ios - ViewController 的presentingViewController 设置错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41114042/

相关文章:

ios - 拖动 uiview iOS

ios - 调整堆栈 View 大小

ios - 在 IB 中使用 "Hides Bottom Bar When Pushed"推送查看时,UITableView 顶部的黑条闪烁

objective-c - AudioUnit 音调生成器在生成的每个音调结束时都会发出一声鸣叫

iphone - 具有滑动效果的 Tabbar Controller

ios - 以编程方式在 ios 中创建水平滑动 View Controller 转换

ios - ScrollView 无法正确调整大小

ios - 我们如何在 google place IOS API 中传递类型、page_token、排序等?

ios - 确定加载当前 UIViewController 的 UIViewController

ios - 增加 dismissViewControllerAnimated() 的持续时间