2

我正在开发一款 iPad 游戏。我有这种情况。当用户/玩家的游戏中心账号未登录时,它会提示一个警告框,让玩家选择:

  1. 登录现有帐户

  2. 建立新帐户

  3. 取消

我对第三个选项(“取消”)感兴趣。当用户单击“取消”选项时,如何处理或分配功能。我试过这个:

- (void) alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if(buttonIndex == 2){ 
        NSLog(@"Cancel called");
    ....

但不工作。还有其他解决方案吗?

谢谢

4

1 回答 1

3

这可能已经很晚了,没有人再关心了,但处理这个问题的方法是在您的 Game Center 身份验证处理程序中。具体来说,如果用户选择“取消”,您将获得一个GKErrorCancelled代码:

- (void) authenticate {

    GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer];
    [localPlayer authenticateWithCompletionHandler: ^(NSError *error) {

        if(error.code == GKErrorCancelled) {
            //this is the case you're interested in
        }

        if(localPlayer.authenticated) {
            //rock on
        }
    }];
}

同样,这篇文章现在可能是古代历史,但是,希望无论如何都能有所帮助:)

于 2012-02-22T19:38:45.223 回答