Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabBar content did not appear (render) in iOS14.0 #11

Closed
Ccapton opened this issue Oct 31, 2022 · 6 comments
Closed

TabBar content did not appear (render) in iOS14.0 #11

Ccapton opened this issue Oct 31, 2022 · 6 comments
Labels
question Further information is requested

Comments

@Ccapton
Copy link

Ccapton commented Oct 31, 2022

In iOS14.0, I use TabBar in a NavigationView, content of the tabbar is invisible, but CustomTabBarStyle works.Without NavigationView, all things go well.

@Ccapton Ccapton changed the title TabBar content did not appear (render) TabBar content did not appear (render) in iOS14.0 Oct 31, 2022
@onl1ner
Copy link
Owner

onl1ner commented Oct 31, 2022

Hello, @Ccapton!

Can you please share the sample of your code?

@onl1ner onl1ner added the question Further information is requested label Oct 31, 2022
@Ccapton
Copy link
Author

Ccapton commented Oct 31, 2022

Hello, @Ccapton!

Can you please share the sample of your code?

NavigationView {
         TabBar(selection: $selection, visibility: $visibility) {
                Button {
                    withAnimation {
                        visibility.toggle()
                    }
                } label: {
                    Text("Hide/Show TabBar")
                }
                .tabItem(for: Item.first)
                
                Text("Second")
                    .tabItem(for: Item.second)
                
                Text("Third")
                    .tabItem(for: Item.third)
            }
            .tabBar(style: CustomTabBarStyle())
            .tabItem(style: CustomTabItemStyle())
}

@Ccapton
Copy link
Author

Ccapton commented Oct 31, 2022

Hello, @Ccapton!
Can you please share the sample of your code?

NavigationView {
         TabBar(selection: $selection, visibility: $visibility) {
                Button {
                    withAnimation {
                        visibility.toggle()
                    }
                } label: {
                    Text("Hide/Show TabBar")
                }
                .tabItem(for: Item.first)
                
                Text("Second")
                    .tabItem(for: Item.second)
                
                Text("Third")
                    .tabItem(for: Item.third)
            }
            .tabBar(style: CustomTabBarStyle())
            .tabItem(style: CustomTabItemStyle())
}

In iOS14.0

@onl1ner
Copy link
Owner

onl1ner commented Oct 31, 2022

Embedding TabBar inside the specific NavigationView is not the best practice, because you should have one TabBar for the whole application. So I see the following possible ways to resolve this issue:

  • So if you are trying to create a tab with the NavigationView in it, you should have something like this:
TabBar(...) {
    NavigationView { ... }
        .tabItem(for: Item.first)

    <...>
}
  • But if you are trying to hide a TabBar inside the specific view you can use the binding that you passed inside visibility parameter to change the visibility of your TabBar

Hope it helps!

@Ccapton
Copy link
Author

Ccapton commented Oct 31, 2022

NavigationView

Thank you very much

Embedding TabBar inside the specific NavigationView is not the best practice, because you should have one TabBar for the whole application. So I see the following possible ways to resolve this issue:

  • So if you are trying to create a tab with the NavigationView in it, you should have something like this:
TabBar(...) {
    NavigationView { ... }
        .tabItem(for: Item.first)

    <...>
}
  • But if you are trying to hide a TabBar inside the specific view you can use the binding that you passed inside visibility parameter to change the visibility of your TabBar

Hope it helps!

Thank you very much!

@onl1ner
Copy link
Owner

onl1ner commented Oct 31, 2022

Happy to help :)

@onl1ner onl1ner closed this as completed Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants