0

' 我对 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];
            }
        }
    }
}

} `

谢谢

奇什蒂

4

0 回答 0