iOS - pushViewController vs presentModalViewController difference

前端 未结 5 829
南旧
南旧 2021-02-01 17:17

What is the difference beetween calling presentModalViewController and pushViewController, when :

  • animation is set to NO (even if yes, th
5条回答
  •  不知归路
    2021-02-01 18:03

    Take a look into the viewControllers in the image

    • The top 2 viewControllers(login & submit) at the top left are disconnected from the tabBarController & NavigationController
    • The rest of the viewControllers are embedded in a NavigationController. They somehow belong to the natural flow of the app.

    Now you have to ask yourself

    Do I need to always show login + submit page every time? It would be pain in the neck for the user to each time go to login even if they logged in last time. These 2 screen really don't fit the natural flow of the screens. So what do we do? We just add them modally using presentViewController

    However for the rest of the viewControllers we want to keep them inside 2 navigation so we can easily go back and forth so we use pushViewController

    For more information I recommend you to see this video The image was also picked from this great answer. It's worthy of a look.

提交回复
热议问题