Updated 4 days ago | GitHub

Understanding Navigation in iOS

Overview

There are three basic types of Navigation mechanisms in iOS:

  1. Push Navigation
  2. Modal Navigation
  3. Tab Navigation

Push Navigation

A push Segue is adding another VC to the navigation stack. This assumes that the VC that originates the push is part of the same navigation controller that the VC that is being added to the stack belongs to. Memory management is not an issue with navigation controllers and a deep stack. As long as you are taking care of objects you might be passing from one VC to another, the navigation controller manages the navigation stack for you. See the image for a visual indication:

Push Navigation

A modal Segue is just one VC presenting another VC modally. The VCs don’t have to be part of a navigation controller. The VC being presented modally is not a child of the presenting VC (child view controllers belong to container view controllers, and a VC’s children array doesn’t include presented view controllers); instead, the presented VC’s presentingViewController property points back to the VC that presented it. The modally presented VC is usually sans any navigation bars or tab bars. The presenting VC is also responsible for dismissing the modal VC it created and presented.

Modal

Tab Bar Navigation

Tab bar controllers are simple-to-use container view controllers (a UITabBarController is not a kind of navigation controller, though each tab can hold one). They are generally used when there are different logical flows in your app and you want to switch from one controller to another.

Tab bar