0

Understood from googling that ViewDidLoad is not called after modally presented view is dismissed because the presenting view controller did not in fact disappear.

But I do want to update my VC after dismissing the second view controller which is modally presented.

Have tried dismiss() function but did not manage to use completion handler of dismiss() to update UI.

Also learnt from googling that NSnotificationCentre could help but really trying to avoid this method.

Any thoughts? Thanks

Tony
  • 1
  • 1
  • 2
  • It doesn't call `viewDidLoad` because the view was already loaded but does it not call `viewDidAppear`? – Phillip Mills Dec 02 '20 at 13:56
  • there are lots of other way to do it like closures or Delegate pattern. or you can add your logic in viewwillappear or viewdidappear on presenting view controller. – CrackIt Dec 02 '20 at 13:58
  • See https://stackoverflow.com/questions/54602662/unified-uiviewcontroller-became-frontmost-detection – matt Dec 02 '20 at 13:59
  • @PhillipMills "but does it not call viewDidAppear" no. Not since iOS 13. – matt Dec 02 '20 at 14:00
  • @PhillipMills Phillips was spot on. After some trial and errors, I realized that viewDidLoad was not executed (even if the modally presented VC is set to be full screen) but viewDidAppear was called. I guess it makes sense (the view did not need to "load", it only "appeared"). I don't really know whether to expect viewDidAppear to be called but it did get called, which fixed my issue. – Tony Dec 06 '20 at 11:55
  • Solution: This issue is finally solved (even though it may not be the most elegant one but it works) by first, setting the modally presented view to be full screen and second, implement the updating of presenting view controller in the method viewDidAppear instead of viewDidLoad. After trail and error, I realized that viewDidAppear gets called after a full-screen modally presented VC is dismissed but viewDidLoad was not called. Cheers to Phillip and Matt for helping out. – Tony Dec 06 '20 at 11:59

0 Answers0