我有以下代码在我的 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
}
}
}
}
可能是什么问题呢?我还阅读了有关在课堂上的某处使用 UIViewControllerRepresentable 将 UIKit 的 ViewController 集成到 SwiftUI 中的信息,但我不明白如何使用它。有人可以帮我吗?