游戏中心登录对话框没有第二次打开

时间:2015-03-30 13:06:32

标签: ios game-center

启动应用程序时,我正在打开游戏中心登录对话框。这是第一次使用。但当用户按下取消按钮时,它会隐藏。然后点击打开排行榜的ui的按钮,虽然如果用户没有登录,我会调用登录方法,但是没有显示登录对话框。这是两种方法......

bool GameSharing::signInPlayer(){
    GKLocalPlayer *player = [GKLocalPlayer localPlayer];
    bool signedIn=false;
    [player authenticateWithCompletionHandler:^(NSError *error) {
        //Just relax and do nothing
    }];
    if (player.isAuthenticated) {

        signedIn = true;
    }

    return  signedIn;
}

void GameSharing::openGameCenterLeaderboardsUI(int lId){
    NSLog(@"Open Leaderboard UI");
    if(iosLeaderboardIds.size() >= lId){
        if (![GKLocalPlayer localPlayer].isAuthenticated) {
            NSLog(@"not authenticated");
            signInPlayer();
        }else{
            NSLog(@"authenticated");
            AppController* appController = (AppController*) [UIApplication sharedApplication].delegate;

            GKLeaderboardViewController* gkController = [[[GKLeaderboardViewController alloc] init] autorelease];
            gkController.leaderboardIdentifier = [NSString stringWithUTF8String:iosLeaderboardIds.at(lId).c_str()];
            gkController.timeScope = GKLeaderboardTimeScopeAllTime;
            gkController.timeScope = GKLeaderboardTimeScopeToday;
            gkController.leaderboardDelegate = appController;

            [appController.viewController presentModalViewController:gkController animated:YES];
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我不确定,但也许在它再次弹出之前有某种延迟?也许功能设计为每天只会弹出一次,除非应用程序重新启动。只是一个猜测。