” 我有一个GKTurnBasedMatchmakerViewController的问题。当我显示GKTurnBasedMatchmakerViewController然后我按“立即播放”按钮找到自动匹配。虽然它的处理我在这个应用程序崩溃后按下取消按钮..它永远不会出现在didFindMatch函数中..它在此之前崩溃。
我们可以在“立即播放”按下时禁用取消按钮吗?
以下是我的GKTurnBasedMatchmakerViewControllerDelegate
代码` #pragma GKTurnBasedMatchmakerViewControllerDelegate函数
// The user has cancelled
- (void)turnBasedMatchmakerViewControllerWasCancelled:(GKTurnBasedMatchmakerViewController *)viewController {
[presentingViewController dismissModalViewControllerAnimated:YES];
if([self.delegate respondsToSelector:@selector(gameCenterViewControllrRemoved)]) {
[self.delegate gameCenterViewControllrRemoved];
}
self.delegate = nil;
presentingViewController = nil;
}
// Matchmaking has failed with an error
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFailWithError:(NSError *)error {
[presentingViewController dismissModalViewControllerAnimated:YES];
if([self.delegate respondsToSelector:@selector(gameCenterViewControllrRemoved)]) {
[self.delegate gameCenterViewControllrRemoved];
}
self.delegate = nil;
presentingViewController = nil;
}
// A turned-based match has been found, the game should start
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{
[presentingViewController dismissModalViewControllerAnimated:YES];
[self setCurrentMatch:match];
GKTurnBasedParticipant *firstParticipant = [match.participants objectAtIndex:0];
if(self.delegate) {
if (firstParticipant.lastTurnDate == NULL) {
// It's a new game!
if ([self.delegate respondsToSelector:@selector(startTurnBasedGame)]) {
[self.delegate startTurnBasedGame];
}
//[self.delegate startTurnBasedGame];
} else {
if ([match.currentParticipant.playerID isEqualToString:[GKLocalPlayer localPlayer].playerID]) {
// It's your turn!
if ([self.delegate respondsToSelector:@selector(takeTurn)]) {
[self.delegate takeTurn];
}
} else {
// It's not your turn, just display the game state.
if ([self.delegate respondsToSelector:@selector(displayLayout)]) {
[self.delegate displayLayout];
}
}
}
}
} `
感谢
奇什蒂