iOS 13中的viewDidAppear问题 [英] viewDidAppear issues in iOS 13
问题描述
我刚刚开始使用iOS 13进行编码,并且在视图控制器功能方面遇到了问题.在iOS 13之前,我使用此功能提供了一个视图控制器
I just started coding with iOS 13 and am having issues with view controller functions. Previous to iOS 13 I had a view controller presented using this function
func presentDetail(_ viewControllerToPresent: UIViewController){
let transition = CATransition()
transition.duration = 0.22
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.view.window?.layer.add(transition, forKey: kCATransition)
present(viewControllerToPresent, animated: false, completion: nil)
}
当关闭时,根视图控制器中的viewDidAppear将触发.现在,在iOS 13中,似乎VC是在根VC之上构建的,并且在关闭时,它不会触发根VC中的viewDidAppear.我必须使用其他功能还是必须完全改变我的方法?根VC viewDidAppear当前会在viewDidLoad以及用户从选项卡栏切换到它时触发,任何建议都很好,谢谢!
And when dismissed, viewDidAppear in the root view controller would trigger. Now in iOS 13 it seems like the VC is built on top of the root VC, and when dismissed it does NOT trigger viewDidAppear in the root VC. Is there a different function I have to use or do I have to completely change my approach? root VC viewDidAppear currently triggers when viewDidLoad and when user switches to it from tab bar, any advice would be great, thank you!
推荐答案
当您关闭视图控制器时,默认的显示样式(即卡片样式)将不会触发 viewDidAppear
.
The default presentation style, which is the card style, will not trigger viewDidAppear
when you dismiss the view controller.
您很可能必须切换到其他触发它的 modalPresentationStyle
.例如,会触发它的一种表示样式是 .fullScreen
You'll most likely have to switch to a different modalPresentationStyle
that will trigger it. One of the presentation style's that does trigger it for example is .fullScreen
例如,对于 viewControllerToPresent
,您想要将其演示样式设置为
So for example, for viewControllerToPresent
you'd want to set it's presentation style to
viewControllerToPresent.modalPresentationStyle = .fullScreen
在展示之前
这篇关于iOS 13中的viewDidAppear问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!