What's the difference between all the Selection Segues?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In iOS development, the concept of segues is foundational when it comes to transitioning between view controllers. There are several types of segues, each offering different behaviors and applications. Specifically, Selection Segues are used when a selection in one view should lead to the presentation of another. Understanding the different types of Selection Segues is crucial for developing effective and intuitive navigation flows in apps. This article explores the primary Selection Segues available in UIKit and SwiftUI, detailing their differences, uses, and implementation techniques.
UIKit Segues
UIKit provides several types of segues, and the choice among them dictates the kind of transition animation and flow control used between view controllers. The primary Selection Segues include the following:
Show (Push)
- Description: The Show (Push) segue is used mainly within navigation controllers. When triggered, this segue pushes the destination view controller onto the navigation stack.
- Technical Explanation: The segue calls the
pushViewController(_:animated:)method on the navigation controller, which maintains the stack-based navigation history. - Use Case: Ideal for tasks that require backward navigation using a navigation bar’s Back button.
Show Detail (Replace)
- Description: Intended for use in split view controllers, the Show Detail segue replaces the currently displayed detail view controller with a new one.
- Technical Explanation: It utilizes the
showDetailViewController(_:sender:)method, particularly useful on devices with larger screens (like iPads) where a master-detail interface is common. - Use Case: Useful for applications that need to display related but distinct detail content alongside a primary list or menu.
Present Modally
- Description: This segue presents the destination view controller as a modal, taking over the entire screen or a portion, depending on the presentation style.
- Technical Explanation: It leverages the
present(_:animated:completion:)method. The presentation can be customized to appear as full-screen, page-sheet, or form-sheet. - Use Case: Appropriate for transient tasks, like showing settings or login screens, where the destination view controller doesn’t need to be part of a navigation stack.
Popover Presentation
- Description: This segue presents the destination view controller as a popover on iPads, providing focused content without a full screen takeover.
- Technical Explanation: Functions through specialized controllers, adapting to the size of the presenting element and view hierarchy. The
UIPopoverPresentationControllermanages the display. - Use Case: Suited for actions or information that require singular attention without breaking the current workflow context.
SwiftUI Navigation
SwiftUI handles navigation differently than UIKit, providing more declarative and flexible approaches. The primary mechanisms include:
NavigationLink
- Description: Binds a navigation action to a view, typically a list item, used to transition to a different view.
- Technical Explanation: SwiftUI's
NavigationLinkencapsulates the view-driven navigation concept where you can declare navigation destinations directly in the view hierarchy. - Use Case: Useful for creating hierarchies between parent and child views, like a list view leading to a detailed view of a selected list item.
Modal Presentation
- Description: Similar to UIKit’s modal, views are presented modally using
sheet()modifiers. - Technical Explanation: Sheets in SwiftUI are a flexible way to present modals. The
sheet()modifier is attached to a view, allowing conditional presentation and dismissal. - Use Case: Effective for tasks that naturally conclude on dismissal, like entering text or selecting options.
Popover
- Description: SwiftUI provides popovers via the
popover()modifier for iPad-specific designs. - Technical Explanation: The
popover()modifier presents a transient view for refined attention, akin to UIKit's popovers, offering an interface that floats over existing content. - Use Case: Great for supplementary information or tools, like displaying extra details or configurations tied to a context.
Table: Selection Segues Summary
| Type | UIKit Mechanism | SwiftUI Mechanism | Use Case & Notes |
| Show (Push) | pushViewController | NavigationLink | Navigating deeper into content Preserves navigation stack |
| Show Detail (Replace) | showDetailViewController | N/A | Split view controllers on iPad Replaces detail content dynamically |
| Present Modally | present | sheet | Modal tasks & independent workflows Full-screen can be achieved with presentation customization |
| Popover Presentation | UIPopoverPresentationController | popover | Targeted, informative views for iPad Without full interface takeover |
By understanding the differences between these selection segues, developers can better design interfaces that provide intuitive and effective user experiences. Choosing the correct segue type for the right context not only enhances navigation logic but also aligns with the platform's human interface guidelines, ensuring a seamless transition and interaction for users.

