Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulator vs Physical Device: NavigationLink broken after one use

Tags:

ios

swift

swiftui

I'm creating an iOS app with SwiftUI. I'm using:

  • Xcode Version 11.3 beta (11C24b)
  • iPad Simulator running iOS 13.3
  • Physical iPad running also iOS 13.3

However, the app behaves different on the two devices. For example on the physical iPad, NavigationLink can only be used once.

This is how it looks on the physical device (NavigationLink is broken after first use) And on the simulator it works perfectly

It is my first iOS app. So I'm wondering how these kind of errors can be circumvented or resolved?

import SwiftUI

enum ExerciseType: String, CaseIterable, Codable, Hashable {
    case vowels = "Vowels"
    case special = "Special Characters"
    case small = "Small Characters"
    case long = "Long Vovels"
}

enum LessonType: String, CaseIterable, Codable, Hashable {
    case hiragana = "Introduction to Hiragana"
    case katakana = "Introduction to Katakana"
    case kanji = "Introduction to Kanji"
}

struct ContentView: View {
    var body: some View {
        NavigationView{
            Form{
                Section(header: Text("Default Lesson")){
                    List{
                        ForEach(LessonType.allCases, id:\.self){ lesson in
                            NavigationLink(destination: LessonView(), label: {Text(lesson.rawValue)})
                        }
                    }
                }
            }
        .navigationBarTitle("iPad NavigationLink")
        }.navigationViewStyle(StackNavigationViewStyle())
    }
}

struct LessonView: View {
    var body: some View{
        Form{
            List{
                ForEach(ExerciseType.allCases, id:\.self){ exercise in
                    NavigationLink(destination: Text(exercise.rawValue), label: {Text(exercise.rawValue)})
                }
            }
        }
    }
}
like image 866
simibac Avatar asked Nov 27 '19 17:11

simibac


2 Answers

The bug is fixed by Apple in iOS 13.3 beta 4. Keep in mind that iOS 13.3 was in beta at the time you tested it. It was not a bug in iOS 13.2, so this is nothing to worry about anymore.

like image 121
Thomas Vos Avatar answered Oct 22 '22 00:10

Thomas Vos


Tested on Xcode 11.3 (11C29)

It's fixed when running on iOS 13.3 device, but not on iOS 13.3 simulator.

like image 36
Jimmy Prime Avatar answered Oct 22 '22 00:10

Jimmy Prime