Sobes.tech
Middle

What happens if you open multiple screens in an app and dismiss the last one?

sobes.tech AI

Answer from AI

If you open multiple screens (ViewControllers) sequentially in an iOS app, they are usually placed in a navigation stack or view hierarchy. When calling the dismiss method on the last opened screen:

  • This screen will be closed and removed from the display.
  • The user will return to the previous screen in the stack.
  • If the last screen was presented modally, dismiss will close exactly that one, without affecting the others.

Example:

// Present a new screen modally
present(newViewController, animated: true, completion: nil)

// To close the last screen
dismiss(animated: true, completion: nil)

Thus, dismiss only affects the last presented screen, returning the user to the previous interface state.

What happens if you open multiple screens in an app… - sobes.tech