Push Segue and Modal Segue can easily make IOS programmers confused. In IOS storyboard programming, we can simply create a segue by ctrl dragging a button to an UIViewController, then we are asked to choose the type of segue, push or modal. The transition effect of push segue and modal segue are quit different. Push segue transits one new view by pushing the old view to left. When the new view is dismissed, it will be push to right and show the old view. Different from push segue, modal segue has four transition effect.

For IOS storyboard programming beginners, it is very hard for them to understand the difference between push segue and modal segue, except the view effect. Sometimes, they want to implement a pushing effect between to simple UIViewControllers. But after we create a push modal from one button to another UIViewController, it will make us disappointed because nothing will happen when we click the button, while it will work if we select modal segue instead of push segue. As a beginner, it took me two days to find the reason why push segue didn’t work at that time.

Actually, these two types of segue are designed for different usage. Push segue are only working with UINavigationController. Modal Segue are designed to fully switch to a new view. When you build the view transition with tab bar, you will understand what I am talking about. If you want to switch views inside tab bar, the modal segue will screw it up. The modal segue will switch to the new view without the tab bar. Please watch the following video, and you will understand what I am saying.

In the above video, when you keep pushing to the green view, you will see two buttons, one for push segue and another one for modal segue. As the video showing, the modal segue will switch to a totally new view without navigation bar and tab bar. When you click modal button to switch back, you can still see the green view, but you lost the navigation and tab bar. The push segue in green doesn’t work as well. In this scenario, it shows the difference between push segue and modal segue very clearly. In next video, it will show you how to implement this example ios app. I think it is very worth to watching, especially for beginners.

In this post, we are talking about the different between push segue and modal segue in IOS programming. We also provide a very good example for combining Navigation controller and tab bar controller to work together. Later, I will show more examples about IOS storyboard programming.

Previous PostNext Post

Leave a Reply

Your email address will not be published. Required fields are marked *