Sobes.tech
Junior — Middle

In what situations is the viewWillAppear method called, but viewDidAppear does not trigger?

sobes.tech AI

Answer from AI

The viewWillAppear method is called every time before the view controller's view appears on the screen, whereas viewDidAppear is called after the view has appeared and is visible.

Situations where viewWillAppear is called but viewDidAppear is not triggered can occur if the transition to the screen was interrupted or canceled before the appearance animation completed, for example:

  • If during the transition animation the user quickly cancels or closes the screen.
  • If in the viewWillAppear method, a modal presentation of another controller occurs, and the current screen has not fully appeared.
  • During programmatic transitions, when viewWillAppear is called but the transition does not complete (due to an error or logic).

Thus, viewWillAppear is called when preparing to appear, and viewDidAppear only if the screen has actually appeared.

In what situations is the viewWillAppear method… - sobes.tech