模拟器与物理设备:一次使用后NavigationLink损坏 [英] Simulator vs Physical Device: NavigationLink broken after one use

查看:90
本文介绍了模拟器与物理设备:一次使用后NavigationLink损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SwiftUI创建一个iOS应用.我正在使用:

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

  • Xcode版本11.3 beta(11C24b)
  • 运行iOS 13.3的iPad模拟器
  • 还运行iOS 13.3的物理iPad

但是,该应用在两种设备上的行为不同.例如,在物理iPad上,NavigationLink只能使用一次.

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

这是我的第一个iOS应用.所以我想知道如何避免或解决这类错误?

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)})
                }
            }
        }
    }
}

推荐答案

在Xcode 11.3(11C29)上测试

Tested on Xcode 11.3 (11C29)

在iOS 13.3设备上运行时已修复,但在iOS 13.3模拟器上未运行.

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

这篇关于模拟器与物理设备:一次使用后NavigationLink损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆