Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

ios - Simulator vs Physical Device: NavigationLink broken after one use

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)})
                }
            }
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...