WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

NavigationView scrolling broken when using TabView

Forums > SwiftUI

Hi all,

With the below code I get a very weird scrolling behaviour in my TabViews, LoginView is called on app launch:

struct LoginView: View {
    @State private var presentContent = false

    var body: some View {

        return NavigationView {
            ZStack{
                NavigationLink(
                    destination: ContentView(),
                    isActive: $presentContent,
                    label: {
                        EmptyView()
                    })

                Button("TEst") {
                    self.presentContent.toggle()
                }
            }

        }
    }
}

struct ContentView: View {
    var body: some View {
        TabView{
            Group{
                List{
                    Text("Item 1")
                    Text("Item 2")
                    Text("Item 3")
                }
            }
            .navigationTitle("Transactions")
            .tabItem {
                Image(systemName: "list.dash")
                Text("Transactions")
            }
            Group{
                List{
                    Text("Item 11")
                    Text("Item 12")
                    Text("Item 13")
                }
            }
            .navigationTitle("Summary")
            .tabItem {
                Image(systemName: "list.dash")
                Text("Summary")
            }
        }
    }
}

Any ideas what that might cause?

   

Sounds trite, but your code compiles and looks fine to me.

"Works for me!"

I am running Simulator with iOS 15.4 on iPhone 8 Plus. What iOS are you running in the simulator?

Please note: The Navigation TItle does not change for me. Once running, the app always shows Transactions above the lists. I never see a title named Summary.

   

Simulator: iPhone 8+ on 15.2 real device: iPhone 8+ on 15.4.1

both behave the same and show the issue

Have you tried jumping between the tabs and scrolling up and down again?

   

Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.