Search code examples
iosswiftswiftuitvosapple-tv

How can I scroll vertically in tvOS with SwiftUI?


I don't know it's a SwiftUI specific problem but I can't scroll vertically in tvOS. It's just simple List that shows items.

var body: some View {
    List(items, id: \.self) { item in
         ItemView(item: item)
    }
}

There are 50+ items, but I can see about 10 of them.

I tried option + arrow keys, also tried with simulator's remote by holding option key. non of them worked. Is there anyone who encountered with it?

Thank you.


Solution

  • On tvOS List content should be active, like buttons, and then you can use Remote, or arrows on keyboard for simulator to scroll through

    (tested with Xcode 11.4)

    var body: some View {
        List(items, id: \.self) { item in
             Button(action: {}) {
               ItemView(item: item)
             }
        }
    }