检测表在 iOS 13 上被取消 [英] Detecting sheet was dismissed on iOS 13

查看:19
本文介绍了检测表在 iOS 13 上被取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 13 之前,呈现的视图控制器用于覆盖整个屏幕.并且,当被解除时,父视图控制器 viewDidAppear 函数被执行.

Before iOS 13, presented view controllers used to cover the entire screen. And, when dismissed, the parent view controller viewDidAppear function were executed.

现在iOS 13默认将视图控制器呈现为一张表,这意味着卡片将部分覆盖底层视图控制器,这意味着不会调用viewDidAppear,因为父视图控制器有从未真正消失过.

Now iOS 13 will present view controllers as a sheet as default, which means the card will partially cover the underlying view controller, which means that viewDidAppear will not be called, because the parent view controller has never actually disappeared.

有没有办法检测到呈现的视图控制器表被关闭?我可以在父视图控制器中覆盖其他一些功能而不是使用某种委托?

Is there a way to detect that the presented view controller sheet was dismissed? Some other function I can override in the parent view controller rather than using some sort of delegate?

推荐答案

有没有办法检测到所呈现的视图控制器表已被取消?

Is there a way to detect that the presented view controller sheet was dismissed?

是的.

我可以在父视图控制器中覆盖的其他一些功能而不是使用某种委托?

Some other function I can override in the parent view controller rather than using some sort of delegate?

没有.某种委托"就是你的方式.使自己成为演示控制器的委托并覆盖 presentationControllerDidDismiss(_:).

No. "Some sort of delegate" is how you do it. Make yourself the presentation controller's delegate and override presentationControllerDidDismiss(_:).

https://developer.apple.com/documentation/uikit/uiadaptivepresentationcontrollerdelegate/3229889-presentationcontrollerdidddismiss

缺乏一个通用的运行时生成的事件来通知你一个呈现的视图控制器,无论是否全屏,已经被解除,确实很麻烦;但这不是一个新问题,因为一直存在非全屏呈现的视图控制器.只是现在(在 iOS 13 中)有更多它们!我在别处专门针对此主题单独进行问答:Unified UIViewController became front"检测?.

The lack of a general runtime-generated event informing you that a presented view controller, whether fullscreen or not, has been dismissed, is indeed troublesome; but it's not a new issue, because there have always been non-fullscreen presented view controllers. It's just that now (in iOS 13) there are more of them! I devote a separate question-and-answer to this topic elsewhere: Unified UIViewController "became frontmost" detection?.

这篇关于检测表在 iOS 13 上被取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆