1

Hi i'm using an TabView with the PageTabViewStyle to give me some kind of horizontally scrollable snapchat interface. My problem is that the TabView doesnt just enable the views to scroll horizontally but also vertically and i would like to prevent that from happening

  1. wanted behavior (horizontal scrolling)
  2. unwanted behavior (vertical scrolling)

Here is the code to reproduce the behavior

import SwiftUI

struct test: View {
    var body: some View {
        TabView {
            Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
            Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
        }.tabViewStyle(PageTabViewStyle())
    }
}

struct test_Previews: PreviewProvider {
    static var previews: some View {
        test()
    }
}

I have tried using

.onAppear(perform: {
   UIScrollView.appearance().bounces = false
 })

one one view

and

.onDisappear(perform: {
   UIScrollView.appearance().bounces = true
 })

on the others but this does not work as well because the appear/disappear seem to be super buggy

Can't wait to recieve some answers Best Xaver

3
  • Have you checked this : stackoverflow.com/a/66817866/14733292 Commented May 5, 2021 at 11:47
  • Yes i have checked that. But sadly this doesnt work for my case as i want to have some screens inside the TabBar to be able to have vertical scrolling. Commented May 5, 2021 at 12:00
  • Let me know if you get any solutions. Commented Jun 25, 2021 at 17:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.