IPhone viewDidAppear stops firing after loading / rejecting a modal view

I start a little crazy with this.

I have an iphone application with a somewhat complicated presentation structure, this is a tabbed application with a view controller or navigation controller on each tab.

The main controller for one tab uses the viewDidAppear callback to reload any data that has changed since the last show, and in most cases this behaves normally. The problem I am facing is that when I navigate to subviews (on the same tab) using the standard push / pop navigation navigation mechanism, viewWillAppear and viewDidAppear on the main screen always fire when I return to it. However, if I load the modal view controller and then fire it, viewWillAppear remains on, but viewDidAppear stops firing.

I am pretty sure that this is due to the need to manually call these callbacks on the modular controller, but I cannot find any help on how to do this correctly. (I only see this viewDidAppear error on the hardware, in the simulator it works as I expected)

If you need further clarification, let me know and thanks for any input.

+3
source share
2 answers

Yes, that’s how it works. You better switch to using viewWillAppear.

This has the added benefit of updating the data before the screen is redrawn.

+3
source

viewDidLoad should be used for one-time installation operations:

  • Header customization
  • ,
  • ,

viewWillAppear: -, . - viewDid/viewWill - UIView. viewDidLoad , , , , . viewDidLoad , , , , , , .

0

Source: https://habr.com/ru/post/1714248/


All Articles