如何在SwiftUI中显示游戏中心配对视图控制器?

如何在SwiftUI中显示游戏中心配对视图控制器?,swift,swiftui,game-center,Swift,Swiftui,Game Center,我正在与SwiftUI和游戏中心合作创建一个多人游戏。在初始化GKMatchmakerViewController之后,我在显示GKMatchmakerViewController时遇到问题,其中包含玩家数量和邀请消息。我尝试使用按钮调用presentMatchmaker()函数,但不起作用。非常感谢您的帮助 func presentMatchmaker() { guard GKLocalPlayer.local.isAuthenticated else {

我正在与SwiftUI和游戏中心合作创建一个多人游戏。在初始化GKMatchmakerViewController之后,我在显示GKMatchmakerViewController时遇到问题,其中包含玩家数量和邀请消息。我尝试使用按钮调用presentMatchmaker()函数,但不起作用。非常感谢您的帮助

func presentMatchmaker() {
        guard GKLocalPlayer.local.isAuthenticated else {
            return
        }
        let request = GKMatchRequest()
        request.minPlayers = 2
        request.maxPlayers = 7

        request.inviteMessage = "You have been challenged..."

        guard let vco = GKMatchmakerViewController(matchRequest: request) else {
            return
        }
        self.ViewController?.present(vco, animated:true)
}