我正在尝试集成 Game Center 以匹配玩家。我正在使用这个非常简单的功能:
- (void)findOpponent {
GKMatchRequest* request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc]
initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;
[[self viewController] presentViewController:mmvc animated:YES completion:nil];
}
我确实有一些回调,从未调用过':
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)theMatch {
NSLog(@"he");
[[self viewController] dismissViewControllerAnimated:NO completion:nil];
GKMatch* match = theMatch;
[match setDelegate:self];
NSLog(@"Ready to start match!");
}
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindPlayers:(NSArray *)playerIDs {
NSLog(@"Super he");
}
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didReceiveAcceptFromHostedPlayer:(NSString *)playerID {
NSLog(@"Wow");
}
当我在我的设备(iPhone 或 iPad)上测试时,都使用 iOS 7.1,我可以从我的应用程序中打开游戏中心,但是当我点击“立即播放”时,我立即收到错误:“找不到玩家”。然而,我的代码中似乎没有一个回调被触发。知道我做错了什么吗?我确实尝试过重置我的 iPad 设置、从 iCloud 注销、重新启动我的设备等。