简体   繁体   English

关闭viewController总是触发viewDidLoad,从不触发viewWillAppear

[英]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.

相关问题 关于viewController的“viewDidLoad”和“viewWillAppear”方法 - About viewController's “viewDidLoad” and “viewWillAppear” methods 在关闭当前ViewController之后快速显示,然后Presenting ViewController不调用viewWillAppear() - Swift after dismiss Current ViewController then the Presenting ViewController not calling viewWillAppear() viewWillAppear 在 viewController 存在时并不总是执行 - viewWillAppear not always executed when viewController is present 关闭新的 UIWindow 不会触发基础 window 中的 viewWillAppear - Dismiss new UIWindow does not trigger viewWillAppear in base window IOS中的viewDidLoad vs ViewWillAppear - viewDidLoad vs ViewWillAppear in IOS viewWillAppear vs Viewdidload ios - viewWillAppear vs Viewdidload ios viewDidLoad和viewWillAppear用途 - viewDidLoad and viewWillAppear Uses 从其他viewController调用方法不会调用viewWillAppear方法的viewDidLoad - Calling a method from a different viewController won't call viewDidLoad of viewWillAppear methods IBOutlet 在 ViewController 方法中始终为零,但在 IBAction 和 Viewdidload 中可以 - IBOutlet always nil in ViewController methods but ok in IBAction & Viewdidload 在调用初始ViewController ViewDidLoad时,CoreData和NSUserDefaults是否始终会加载? - Will CoreData and NSUserDefaults have always loaded by the time the initial ViewController ViewDidLoad is called?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM