I’m implementing a carousel view for tvOS. In its simplest version, it would be:
struct HorizontalCarouselComponent: View {
let contents: [ContentViewModel]
var body: some View {
TabView {
ForEach(contents) { content in
Text(content.title)
.focusable(true)
}
}
.tabViewStyle(.page)
}
}
With this version, I can see the content correctly and also the pagination. However, when I navigate using the arrow keys on the Apple TV simulator, I notice that some elements of the carousel become unreachable. For example, I can move two positions to the right, and even though there are two more positions, I cannot continue moving forward.
I have tried using TabView
with selection
or setting the focus manually with @FocusState
and focused
, but none of them seem to work. What I expect is to reach every position of the pagination using the arrow keys or the remote.
Do you have any ideas on what might be happening?
Should I go for ScrollView
and forget about TabView
?