Compile Swift Logo

Creating a Master Detail View with Navigation

The Problem

You are creating an application using SwiftUI and need to have a master detail view with navigation between them.

The Solution

This is something that SwiftUI has really simplified, we do not need to worry about storyboards or prepareForSegue and all the code that goes with that.

It now just takes a few lines of code using a NavigationView and NavigationLink to have a working system in very little time.

The Steps

  1. Wrap the view in a NavigationView tag
  2. Add a NavigationLink tag to the item you want to touch on to perform the navigation
  3. Create the detail view that you will be navigating to during step 2

The Video

Back

Copyright 2024 PeterWitham

Facebook Instagram Twitter Mastodon GitHub