简体   繁体   中英

TabView doesn't show text on first view SwiftUI

The problem: When I lunch the app, the first tabview doesn't display the name below. I have to go to another view and come back for it to show. Why?

struct MotherView : View {

var body: some View {
    VStack {
        if viewRouter.currentPage == "onboardingView" {
            OnboardingView()
        } else if viewRouter.currentPage == "homeView" {
            TabView {
                HomeView()
                    .tabItem {
                        Image(systemName: "house")
                        Text("Menu")
                }

                SettingsView()
                    .tabItem {
                        Image(systemName: "slider.horizontal.3")
                        Text("Order")
                }
            }


        }
    }
}
}

在此处输入图像描述

We can just guess, because you didn't show us the code of your HomeView. Nevertheless I guess in your HomeView you have this line .navigationBarTitle("", displayMode: .inline) .

Remove it and it will work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM