【问题标题】:iOS app blank navigationView opening screen on some device simulators and not othersiOS应用程序空白navigationView在某些设备模拟器上打开屏幕而不是其他设备
【发布时间】:2021-03-31 13:08:40
【问题描述】:

我使用 XCode 12.2 在 Swift 5 中编写了一个应用程序

该应用程序及其所有功能可在以下模拟器上运行:iPhone 8、iPhone SE 2nd Gen、iPhone 11 Pro、iPhone 12、iPhone 12 Pro 和 iPhone 12 Mini

所有 iPad、iPhone 8 plus、iPhone 11、iPhone 11 Pro Max 和 iPhone 12 Pro Max 都会出现此问题。

我不知道该怎么做,正在考虑提交错误报告/TSI,但我想确保我的设计没有明显的问题。

以下是我的内容视图的结构。我删除了一些我认为无关紧要的东西,以简明扼要地说明结构。我还附上了正常运行的初始视图与失败的视图的图像。Proper Opening ScreenProblem opening Screen。我还在真正的 iPhone SE 2nd gen 和 iPhone 8 上运行它,得到了相同的结果。 提前致谢。

struct ContentView: View {
//@State vars
    var body: some View {
        NavigationView{
            ZStack{
                Image("image")
                VStack{
                    Spacer()
                    HStack{
                        Text("text")
                            .bold()
                            .foregroundColor(.white)
                            .font(.largeTitle)
                        Image("image2")
                    }.offset(y:10)
                    Form {
                        Section(header: Text("INITILIZATION SETTINGS")){
                            TextField("t1", text: $t1)
                            TextField("t2", text: $t2)
                            Stepper(value: $s1, in: 1...240){
                                Text("s1: \(s1)").onChange(of: s1, perform: { value in
                                    playSound(sound: "sound1", volume: 0.3)
                                })
                            }
                        }
                    }.frame(minWidth: 0, idealWidth: 400, maxWidth:400, minHeight: 0, idealHeight: 100, maxHeight: 180, alignment: .center).border(Color.black, width: 7)
                    VStack()
                    {
                        NavigationLink(destination: otherView().onAppear{playSound(sound: "sound2")}, label: {
                            Text("label")
                        }).padding().background(Color.white).border(Color.black, width: 2).cornerRadius(3.0)

                        NavigationLink(destination: otherView2()) {
                            Text("label2").padding(5).background(Color.white).border(Color.black, width: 2).cornerRadius(3.0).offset(y:-5)
                        }
                    }
                    Spacer()
                }
            }
        }.navigationBarTitle("").navigationBarHidden(true)
    }
}

【问题讨论】:

    标签: ios swift iphone xcode swiftui-navigationview


    【解决方案1】:

    解决方案非常简单,只是设置问题。在这个 Hacking With Swift 视频 [https://youtu.be/nA6Jo6YnL9g?t=1720][1] 中在大约 29 分钟内回答。

    大屏幕 iOS 设备使用默认的 navigationView{} 设置自动将屏幕分割成多个视图。{}我不知道空白屏幕是关于什么的,但这解决了问题 只需添加视图修饰符 .navigationViewStyle(StackNavigationViewStyle())

    我想我会自己回答而不是删除帖子,因为我在网上找到解决方案时遇到了很多麻烦!希望这会对某人有所帮助!

    【讨论】:

      猜你喜欢
      • 2021-07-15
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-26
      • 2021-06-03
      • 2015-08-03
      相关资源
      最近更新 更多