【发布时间】:2020-04-23 18:12:40
【问题描述】:
标题说明了一切 - 我无法在 tvOS 上的 SwiftUI 中专注于 UIViewRepresentable。任何符合View 协议的视图都可以毫无问题地聚焦,但UIViewRepresentable 和UIViewControllerRepresentable 都不能。
有什么想法吗?
此代码有效:
struct ContentView: View {
var body: some View {
Text("Hello, World!")
.focusable()
.onExitCommand {
print("Menu button pressed")
}
}
}
这个没有:
struct ContentView: View {
var body: some View {
ViewRepresentable()
.focusable()
.onExitCommand {
print("Menu button pressed")
}
}
}
struct ViewRepresentable: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
let view = UIView()
view.backgroundColor = .red
return view
}
func updateUIView(_ uiView: UIView, context: Context) {
}
}
谢谢!
【问题讨论】:
-
你有什么解决办法吗?我在尝试让 UISearchController 在 SwiftUI 应用程序中工作时遇到同样的问题
-
@GuyBrooker 这个有什么更新吗?与
UISearchController有同样的问题
标签: swiftui tvos apple-tv uiviewrepresentable