iOS 13, When we enabled the horizontal scrollview(Test View) inside the main scrollview, scrollTo function doesn't working.
Looking some solution to put horizontal scrollview inside the vertical scrollview.
Thank you.
var body: some View {
VStack(alignment: .leading) {
//MARK:- Top horizontal category list
HStack(spacing: 30) {
ForEach(categories, id: \.self) { category in
Button(action: {
if let proxy = proxy {
proxy.scrollTo(category, alignment: .top, animated: true)
}
}) {
Text(category)
.fixedSize(horizontal: true, vertical: true)
}
}
}
.padding(.horizontal)
//MARK:- Main vertical ScrollView
ScrollView(.vertical, showsIndicators: false) { proxy in
VStack(alignment: .leading, spacing: 30) {
//MARK:- Horizontal ScrollView
ScrollView(.horizontal, showsIndicators: false) {
//When we enabled the horizontal scrollview here, scroll to function doesn't working.
HStack{
Text("Test view")
.font(.title)
.bold()
}
}
//MARK:- Main " Subviews
ForEach(categories, id: \.self) { category in
VStack(alignment: .leading) {
Text(category)
.font(.largeTitle)
.foregroundColor(Color.black)
.onTapGesture {
proxy.scrollTo(category)
}
VStack(alignment: .leading) {
ForEach(0..<5) { index in
Text("Subview \(index)")
.padding()
}
}.padding(.top)
}
.scrollId(category)
}
}
.onAppear { self.proxy = proxy }
}
}
.padding(.horizontal)
}
iOS 13, When we enabled the horizontal scrollview(Test View) inside the main scrollview, scrollTo function doesn't working.
Looking some solution to put horizontal scrollview inside the vertical scrollview.
Thank you.