我正在与SwiftUI和Game Center一起创建多人游戏。用播放器和邀请消息的数量初始化它后,我无法呈现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)
}