NavigationView黑屏

问题描述

我开发了第一个SwiftUI应用。 无法解决此问题。 NavigationView返回空白而不是我的视图。

struct Home: View {
    @SwiftyUserDefault(keyPath: \.gridEnabled) var gridEnabled
    @State private var grid = false
    @State private var selectedIndex: Int = 0
    @State private var openAbout: Int? = nil

    init() {
        UITabBar.appearance().shadowImage = UIImage()
        UITabBar.appearance().backgroundImage = UIImage()
        UITabBar.appearance().isTranslucent = true
        UITabBar.appearance().backgroundColor = UIColor(named: "ColorPrimaryDark")
        UITabBar.appearance().unselectedItemTintColor = UIColor.white
    }
    
    var body: some View {
        let menuView = MenuView(onMenuSelected: {
            index in
            print("Selected: \(index)")
            if index == 3{
                self.openAbout = 10
                return
            }
            self.selectedIndex = index
        })
        
        return
                NavigationView{
                    ZStack{
                        NavigationLink(destination: About().navigationBarTitle(Text("About the app"),displayMode: .inline),tag: 10,selection: self.$openAbout) {
                          EmptyView()
                            }.hidden()
                        TabView(selection: $selectedIndex) {
                            SoundList(grid: self.grid)
                            .tabItem {
                                    Image("SoundIcon").renderingMode(.template)
                                    Text("All sounds")
                            }
                            .tag(0)
                            SoundList(grid: self.grid,popular: true)
                            .tabItem {
                                    Image("PopularIcon").renderingMode(.template)
                                Text("Popular")
                            }
                            .tag(1)
                            Favorite()
                            .tabItem {
                                    Image("FavoriteIcon").renderingMode(.template)
                                    Text("Favorite")
                                }
                        .tag(2)
                        
                        }            .listStyle(GroupedListStyle()).accentColor(Color("ColorAccent"))
                        .navigationBarTitle(Text("SleepGo"),displayMode: .inline).navigationBarColor(.clear).navigationBarItems(leading: Button(action: {
                            menuView.toggle()

                        },label: {Image("MenuIcon")}),trailing: Button(action: {
                            self.gridEnabled = !self.gridEnabled
                            self.grid = self.gridEnabled
                        },label: {Image(self.grid ? "GridIcon" : "ListIcon")})).background(Image("Background2").resizable().edgesIgnoringSafeArea(.all))
                    }
                    menuView
                }.navigationViewStyle(StackNavigationViewStyle())
        }
}

在iOS 13.1.2(iPhone 7)上进行测试。 在这里,我看到了NavigationView内的空白屏幕。

在iOS 13.7(iPhone 11)上进行测试 没关系正常显示。

如何解决?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...