我正在尝试使用.quickLookPreviewiOS 14、macOS 11 macCatalyst 14 中引入的视图修改器,但Value of type 'some View' has no member 'quickLookPreview'每次尝试在 macOS 或 mac Catalyst 目标上使用该修改器时都会收到此错误。在 iOS 上,这工作得很好。在 Mac 上呈现此修改器的正确方法是什么?
import SwiftUI
import QuickLook
struct ContentView: View {
@State var documentUrl: URL?
var body: some View {
NavigationView {
ZStack {
Button("Press Me", action: {
documentUrl = URL(fileURLWithPath: "somelocalfileURLPath")
})
}
.navigationTitle("Open File")
.quickLookPreview($documentUrl)
}
}
}
Run Code Online (Sandbox Code Playgroud)
Xcode 13.1 MacOS 12.1
我有以下代码可以在我的 SwiftUI 应用程序中对 Game Center 中的本地玩家进行身份验证。如果玩家尚未登录,我希望 Game Center 提示用户登录,但这不会发生。
class AppSettings: UINavigationController {
func authenticateUser() {
let localPlayer = GKLocalPlayer.local
localPlayer.authenticateHandler = { vc, error in
guard error == nil else {
print(error?.localizedDescription ?? "")
return
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?我还阅读了关于在我班级的某处使用 UIViewControllerRepresentable 将 UIKit 的 ViewController 集成到 SwiftUI 中的内容,但我不明白如何使用它。有人可以帮我吗?
gamekit game-center swift swiftui uiviewcontrollerrepresentable
我正在开发一个 SwiftUI iOS 应用程序,最初是从 A WindowGroup 开始的。在另一个视图中,我决定需要将该视图呈现为 DocumentGroup 场景,以利用它附带的所有功能。我不希望应用程序的入口点是 DocumentGroup 场景。我只是希望我的应用程序的入口点是 WindowGroup 场景,然后在 WindowGroup 场景的另一个视图中,我想调用 DocumentGroup 场景来打开,就好像该应用程序是基于文档的应用程序一样。任何帮助都感激不尽。谢谢
swiftui ×3
swift ×2
game-center ×1
gamekit ×1
ios ×1
mac-catalyst ×1
macos ×1
quicklook ×1
uiviewcontrollerrepresentable ×1
viewmodifier ×1