Tuesday, February 13, 2024
HomeiOS Developmentios - Tabview default animation would not happen for the primary time...

ios – Tabview default animation would not happen for the primary time if switching tabs programatically


I observed after I’ve embedded TabView into NavigationStack, a default animation whereas switching between tabs (when urgent Subsequent button) has disappeared. So transition to a subsequent tab is immediate. Right here is a part of code I’m utilizing:

  var physique: some View {
        
        NavigationStack {
            TabView(choice: $viewModel.choice) {
                ForEach(viewModel.onboardingData, id: .self) { knowledge in
                    OnboardingView(knowledge: knowledge)
                        .tag(knowledge.identifier)
                }
            }
            .tabViewStyle(.web page(indexDisplayMode: .at all times))
            .indexViewStyle(.web page(backgroundDisplayMode: .at all times))
            HStack {
                skipButton
                Spacer()
                nextButton
            }
        }
    }

and the button:

 non-public var nextButton: some View {
        Button(motion: {
            withAnimation {
                viewModel.subsequent()
            }

    }) {
        if viewModel.choice == .fourth {
            NavigationLink(vacation spot: HomeView()) {
                button(textual content: "Let's begin")
            }
        } else {
            button(textual content: "Subsequent")
        }
    }
}

If I take away NavigationStack, issues will work, however proper now, just for the primary merchandise (when going from first to the second tab) animation just isn’t taking place. I assume its in all probability one thing apparent, however I do not perceive it.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments