0

For learning purposes I am trying to make a TVOS 16.1 app. I load data in via an API. The problem that I cannot solve is as follows;

When images are loaded in and presented in a LazyVGrid with 4 columns, and I am at the bottom of the list - when I scroll up the LazyVGrid while pressing and keep holding the 'up' button on my remote control, LazyVGrid is losing focus and the menu bar at the top will receive the focus. It only scrolls up a line or 4 or so and then the focus is gone.

the TVShowCard is a view that will create buttons which will hold the image of the tvshow.

 ScrollView(.vertical) {
        LazyVGrid(columns: [
            GridItem(.flexible()),
            GridItem(.flexible()),
            GridItem(.flexible()),
            GridItem(.flexible())
        ], spacing: 20) {
            ForEach(top_Rated_TVShows, id: \.self) { tvshow in
                TVShowCard(tvshow: tvshow)
            }
        }
  }

When I do exactly the same using LazyVStack as follows, it works good. I can press & hold the up or down button and it will scroll through the entire list :

    ScrollView(.vertical) {
        LazyVStack {
    
    Grid {
        ForEach(top_Rated_TVShows.indices, id: \.self) { index in
            if index % 4 == 0 {
                GridRow {
                    ForEach(0..<4, id: \.self) { subIndex in
                        if index + subIndex < top_Rated_TVShows.count {
                            TVShowCard(tvshow: top_Rated_TVShows[index + subIndex])
                                .frame(maxWidth: 400)
                        } else {
                            Image(systemName: "placeholder")
                                .frame(maxWidth: 400)
                        }
                    }
                }
            }
        }
    }
}
}

But it seems to me that the performance of LazyVGrid is much better, the code is also easier to understand and read. So I prefer LazyVGrid, but bcs of this scrolling issue it is unusable.

Does anyone know what might cause this problem and how to solve it ?

I am trying to use LazyVGrid in TVOS 16.1, but when I am at the bottom of the list and scroll up. After a few scrolls it is losing focus, and the focus will go to the menu bar at the top of the screen.

burnsi
  • 6,194
  • 13
  • 17
  • 27

0 Answers0