gpt4 book ai didi

ios - UIViewController.dismiss() 不调用 presentingViewController.dismiss()

转载 作者:行者123 更新时间:2023-11-29 00:04:49 27 4
gpt4 key购买 nike

apple documentation在 UIViewController dismiss(animated:completion:) 上说

The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal.

但是当我覆盖呈现 Controller 的关闭时

override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil)

它没有被调用

ViewController1 -> 当前 ViewController2

ViewController2.dismiss -> 从 ViewController2 调用 dismiss 并且 ViewController1.(override)dismiss 没有被调用

最佳答案

根据 present(_:animated:completion:) 的文档:

The object on which you call this method may not always be the one that handles the presentation. Each presentation style has different rules governing its behavior. For example, a full-screen presentation must be made by a view controller that itself covers the entire screen. If the current view controller is unable to fulfill a request, it forwards the request up the view controller hierarchy to its nearest parent, which can then handle or forward the request.

对于 iPhone(水平紧凑环境),它默认使用全屏模式。所以这里的 ViewController1 可能不是 'presentingViewController'。

关于ios - UIViewController.dismiss() 不调用 presentingViewController.dismiss(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48386582/

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