[英]dismiss viewController always trigger viewDidLoad and never viewWillAppear
I have a tab bar, in the last tab I have a UIViewController A, that have a button inside, and when you tap on it it is presenting an UIViewController B : 我有一个标签栏,在最后一个标签中,我有一个UIViewController A,里面有一个按钮,当您点击它时,它会显示一个UIViewController B:
let bVC = B()
bVC.settingsPresenter = self
self.present(bVC, animated: true, completion: nil)
When the user is in B and wants to get out of the screen, there is a button that calls this method on A (not B) : 当用户在B中并且想要退出屏幕时,有一个按钮在A(不是B)上调用此方法:
self.dismiss(animated: true, completion: nil)
So when I arrive on the tab for the first time, it calls viewDidLoad then viewWillAppear on A. If I go to the first tab then come back to the last, only viewWillAppear on A. Everything looks normal. 因此,当我第一次到达选项卡时,它将调用viewDidLoad,然后在A上调用viewWillAppear。如果我转到第一个选项卡,则返回到最后一个,仅在A上调用viewWillAppear。一切看起来都很正常。
But when I dismiss B, viewDidLoad of A is called, and not even viewWillAppear... how can I make it the inverse (you know the logical way as the view is already loaded and I only need to be notify that the tab will appear) 但是当我关闭B时,会调用A的viewDidLoad,甚至不会调用viewWillAppear ...如何使其相反(您知道逻辑方式,因为视图已加载,所以我只需要通知该选项卡将出现)
if the ViewController is loading but showing another one, it will never view will appear as the other view controller it is presenting will appear 如果ViewController正在加载但显示了另一个视图控制器,则它将永远不会出现,因为它将显示另一个视图控制器
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.