TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

TabView inside ScrollView

Forums > SwiftUI

Hi, I´m stuck on this problem, basically I have a tabview that can be switch by swiping, the problem is when the tabs have different heights then the swipe doesn't work properly. Any ideas on what can be causing the issue and how to fixed ? Been stuck in this for over 2 weeks now please help

https://ibb.co/myJkQBY


import SwiftUI

struct tabTest: View {

    @State private var selectedTab = 0

    var body: some View {
        ScrollView{
            VStack(){

                ZStack{
                    Circle().frame(width: 150, height: 150).foregroundColor(.blue)
                    Image(systemName: "person.fill").font(.system(size: 90)).padding(0)
                }

                HStack{
                    VStack{

                        Text("Option 1").foregroundColor(.blue)
                        Image(systemName: "folder").font(.system(size: 20)).padding(0)

                    }.frame(maxWidth: .infinity).onTapGesture {
                        self.selectedTab = 0
                    }

                    VStack{

                        Text("Option 2").foregroundColor(.blue)
                        Image(systemName: "paperplane").font(.system(size: 20)).padding(0)

                    }.frame(maxWidth: .infinity).onTapGesture {
                        self.selectedTab = 1
                    }

                }

                TabView(selection: self.$selectedTab){
                    LazyVStack{
                        ForEach((1...100), id: \.self) {
                            Text("\($0)…")
                        }

                    }.tag(0)

                    VStack{

                        Text("Im smaller")

                    }.tag(1)
                }.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))

            }.frame(maxWidth: .infinity)
        }
    }
}

2      

Same here, Did you find a way to solve the issue?

2      

Hello, currently running into the same exact problem ! When switching between tabs it re-adjust the size and thus it is not smooth at all .. Did you found any solutions?

2      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

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.