1

在 iOS 6 上,当玩家未登录并尝试使用 GameCenter 时,会弹出 UIAlertView 和我在标题中输入的文本。“游戏中心不可用玩家未登录”。我的问题是可以用我自己的界面元素替换 UIAlertView 吗?

[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error)
            {
                    if ([[GKLocalPlayer localPlayer] isAuthenticated])
                    {
                        NSLog(@"[gamecenter] player authenticated: %@\n", [GKLocalPlayer localPlayer]);
                        [self gamecenterLoadAchievements];

                        [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
                        {
                            // Insert application-specific code here to clean up any games in progress.
                            if (acceptedInvite)
                            {
                                NSLog(@"Accepted invitation");

                                isInvited = YES;

                                [[GameLevel sharedGameLevel] setCurrentGameMode:GameModeGameCenter];

                                GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
                                mmvc.matchmakerDelegate = self;

                                AppDelegate * delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
                                [delegate.viewController presentModalViewController:mmvc animated:YES];

                            }
                            else if (playersToInvite)
                            {
                                NSLog(@"Players to invite");

                                GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
                                request.minPlayers = 2;
                                request.maxPlayers = 2;
                                request.playersToInvite = playersToInvite;

                                GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
                                mmvc.matchmakerDelegate = self;
                                [presentingViewController presentModalViewController:mmvc animated:YES];
                            }

                        };
                    }
                    else
                    if (viewController)
                    {
                        AppDelegate          *delegate        = (AppDelegate *) [UIApplication sharedApplication].delegate;
                        NavigationController *_viewController = delegate.viewController.navController;

                        [_viewController presentViewController: viewController animated: YES completion:nil];
                    }
                    else
                    {
                        NSLog(@"[gamecenter] %@\n", error);

                        gcLoginFailed = YES;
                        if ([[error domain] isEqualToString:GKErrorDomain])
                        {
                            if ([error code] == GKErrorNotSupported)
                                gcIsSupported = NO;
                            else
                                if ([error code] == GKErrorCancelled)
                                    gcLoginCancelled = YES;
                        }
                    }
            };
4

1 回答 1

0

只是不要使用 UIAlertView 使用您自己的图形和 UIButton

如果您在身份验证中使用 disableGameCenter 方法,请不要使用它,而是使用整数等 int isPlayerSignedIn 。只需将其返回 1 或 0 。所以 ;

if (isPlayerSignedIn==0) {

   //display your graphics

} 
else do nothing .

编辑 :

else
if (viewController)
{
    AppDelegate          *delegate        = (AppDelegate *) [UIApplication sharedApplication].delegate;
    NavigationController *_viewController = delegate.viewController.navController;
    [_viewController presentViewController: viewController animated: YES completion:nil];
}

只是如果你不使用这些代码行你会发现你没有得到那个 UIAlertView

然后你可以实现一个“游戏中心不可用”的员工,但你也必须实现一个登录屏幕。

于 2012-12-05T18:03:29.777 回答