Learn Courses My Dashboard

Learning App Lesson Display Issue

I downloaded and built the Learning App based on resource files of “IOS Databases (SwiftUI) - Module 2 - Lesson 4”. After running the App on Iphone 12 simulator, I clicked the first module “Learn Swift”. It shows a list of 10 lessons. I clicked the first lesson “Constants and Varaiables”. It shows the details screen but immediately returns to the parent screen, i.e. the list of 10 lessons. I clicked other lessons and the same issue happened. I try to run the original App in “IOS Foundations (SwiftUI) - Module 5: Learning App”. And it behaved the same.

The App used to work. Don’t know if the Xcode platform or other reasons have caused this problem.

Lessons 15 and 16 of Module 5 (Learning App) deal with two different bugs. Have a look at those lessons and implement the workarounds indicated.

What version of Xcode are you using?

Thanks. I am using Xcode Version 13.1 (13A1030d). Btw, the issue I encountered seems not related to index out of range (Lesson 15) or test result showing (Lesson 16) of Learning App. It is about showing of Lesson Details. The screen did show but it pops back immediately back to the list of lessons.

The issue is related to the way a NavigationLink works. As I understand it, in Xcode 13 and iOS 15 there is a modifier you need to add to the NavigationLink that solves the problem.
Give that a try.

Added the codes as attached in the source file ContentView.swift. Yet the same issue persists.

The modifier is in the wrong place. Place it after the closing parenthesis of the NavigationLink rather than inside it.

Rather than providing a screen shot of your code, copy it and paste it in as text in a reply (Preferrably all the code from ContentView rather than snippets).

Place 3 back-ticks ``` on the line above your code and 3 back-ticks ``` on the line below your code so that it is formatted nicely in the reply. The 3 back-ticks must be the ONLY characters on the line. The back-tick character is located on the same keyboard key as the tilde character ~ (which is located below the Esc key). You can also highlight an entire code block and click the </> button on the toolbar to wrap the block for you.

This also makes it easier for anyone assisting as they can copy the code and carry out some testing.

Many thanks for your advice. The ContentView codes are pasted below. Please see if the modifier .navigationViewStyle is added correctly. I ran the codes but the problem still appeared.

import SwiftUI

struct ContentView: View {
    @EnvironmentObject var model: ContentModel
    var body: some View {
        ScrollView {
            LazyVStack {
                // Confirm that currentModule is set
                if model.currentModule != nil {
                    ForEach(0..<model.currentModule!.content.lessons.count) { index in
                                    .onAppear(perform: {
                            label: {
                                ContentViewRow(index: index)
            .navigationBarTitle("Learn \(model.currentModule?.category ?? "")")

The issue is fixed after moving the modifier to the closing parenthesis of the NavigationView. Thanks again for your advice.

Ah yes, I was relying on memory (a bad one at that) rather than looking at the screen.