gpt4 book ai didi

ios - 源 View Controller 与呈现 View Controller

转载 作者:行者123 更新时间:2023-12-01 15:59:03 25 4
gpt4 key购买 nike

我正在读一本书,其中指出源 View Controller 不一定是呈现 View Controller 。源 VC 是调用 presentViewController:... 的那个。方法,而呈现的 VC(它的 View )是被呈现的 VC View 遮蔽的那个。我想不出一个例子,其中呈现的 VC 与源 VC 不同。请提供一些。谢谢

书中文字:

“原主播:
presentViewController:animated:completion: 发送到的 View Controller 。 Apple 有时将此 View Controller 称为源; “原始主持人”是我自己的术语。
呈现的 View Controller 被设置为原始呈现者的呈现 View Controller 。

呈现 View Controller :
呈现的 View Controller 的presentingViewController。这是 View Controller ,其 View 被呈现的 View Controller 的 View 替换或覆盖。默认情况下,它的 View 是整个界面的 View Controller ——即 Root View Controller 或已经存在的呈现 View Controller 。它可能与原始演示者不同。
呈现的 View Controller 被设置为呈现 View Controller 的presentedViewController。因此,呈现的 View Controller 可能是两个不同 View Controller 的呈现 View Controller 。”

最佳答案

在学习 View Controller 转换时,我问自己同样的问题,特别是在尝试理解 animationControllerForPresentedController:presentingController:sourceController: 时。来自 UIViewControllerTransitioningDelegate 的方法协议(protocol)。斗争是关于 presentingController 之间的区别。和 sourceController论据。

我在 View Controller Programming Guide 中找到了答案.您可以在 中找到以下内容以模态方式呈现 View Controller 部分:

The view controller that calls the presentViewController:animated:completion: method may not be the one that actually performs the modal presentation. The presentation style determines how that view controller is to be presented, including the characteristics required of the presenting view controller. For example, a full-screen presentation must be initiated by a full-screen view controller. If the current presenting view controller is not suitable, UIKit walks the view controller hierarchy until it finds one that is. Upon completion of a modal presentation, UIKit updates the presentingViewController and presentedViewController properties of the affected view controllers.



这意味着“源” View Controller 概念不是您提到的书的作者随机创建的。

关于ios - 源 View Controller 与呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30082354/

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