检测表在iOS 13上被驳回 [英] Detecting sheet was dismissed on iOS 13
问题描述
在iOS 13之前,展示了用于覆盖整个屏幕的视图控制器.并且,在关闭后,将执行父视图控制器viewDidAppear
函数.
现在,iOS 13默认将表单显示为视图控制器,这意味着卡将部分覆盖基础视图控制器,这意味着将不会调用viewDidAppear
,因为父视图控制器从未真正消失过. /p>
是否可以检测到所显示的视图控制器工作表已被取消?我可以在父视图控制器中覆盖其他一些功能,而不是使用某种委托?
是否可以检测到所显示的视图控制器工作表已被关闭?
是的
我可以在父视图控制器中重写某些其他功能,而不是使用某种委托?
不. 某种代表"就是您的工作方式.使自己成为演示文稿控制器的委托,并覆盖presentationControllerDidDismiss(_:)
.
缺少一个一般的运行时生成的事件,通知您所显示的视图控制器(无论是否为全屏)已被关闭,这确实很麻烦;但这不是一个新问题,因为始终存在非全屏显示的视图控制器.仅仅是现在(在iOS 13中),它们更多了!我在其他地方对此主题进行了单独的问答:>统一的UIViewController成为最前面的";检测?.
Before iOS 13, presented view controllers used to cover the entire screen. And, when dismissed, the parent view controller viewDidAppear
function were executed.
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?
Yes.
Some other function I can override in the parent view controller rather than using some sort of delegate?
No. "Some sort of delegate" is how you do it. Make yourself the presentation controller's delegate and override presentationControllerDidDismiss(_:)
.
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屋!