我想viewController
为我的游戏设置匹配。为此,我将GKMatchmakerViewControllerDelegate
委托添加到我的 mainUIViewController
中Home
,使其看起来像:
class Home: UIViewController, GKGameCenterControllerDelegate, GKMatchmakerViewControllerDelegate {
要加载配对界面,我使用以下代码:
func openMatchmaker() {
var gcViewController: GKMatchmakerViewController = GKMatchmakerViewController(rootViewController: self)
gcViewController.matchmakerDelegate = self
gcViewController.hosted = false
gcViewController.matchRequest.minPlayers = 2
gcViewController.matchRequest.maxPlayers = 2
gcViewController.matchRequest.defaultNumberOfPlayers = 2
self.showViewController(gcViewController, sender: self)
self.navigationController?.pushViewController(gcViewController, animated: true)
}
class Home: ...
但是,当我尝试运行代码时,我收到以下错误。错误消息说:
Type 'Home' does not conform to protocol `GKMatchmakerViewControllerDelegate`.
为什么会这样?