我已经设置了一个非常简单的 SwiftUI tvOS 应用程序。我在使用 Focus 引擎时遇到了困难。当应用程序启动时,它专注于“启动”,这是可以理解的。向下滑动,转到 StackView。在项目上向左/向右滑动效果很好。除了我无法向上滑动以进入 Launch,无论我在哪里尝试。
目标是向上滑动应该总是向上启动按钮(关注单元格会改变上面的内容)
我在这里做错了什么吗?我的印象是我没有做任何特别或复杂的事情。谢谢
这是我的代码:
struct ContentView: View {
@ObservedObject private var viewModel = EnvironmentsViewModel()
@State private var currentEnvironment: Environment?
var environments: [Environment]?
var body: some View {
GeometryReader { geometry in
VStack(spacing: 50) {
BannerView(environment: currentEnvironment)
.frame(height: geometry.size.height * 0.6)
.clipped()
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .center, spacing: 50) {
ForEach(environments ?? viewModel.environments) { environment in
Button(action: {
currentEnvironment = environment
}) {
EnvironmentCard(title: environment.title, subtitle: "Coming Soon", image: environment.image, isFocused: environment.title == …Run Code Online (Sandbox Code Playgroud)