2

关闭任何 Gamecenter 覆盖后,覆盖正确消失,我的游戏窗口再次显示,但它不响应触摸。我搜索了谷歌的答案并提出了很多建议,但没有任何效果。这是我当前的代码:

 GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil)
    {
       window = [[UIApplication sharedApplication] keyWindow];
       gameView = [[window subviews] objectAtIndex:0];

       gameCenterController.gameCenterDelegate = self;
       gameCenterController.viewState = GKGameCenterViewControllerStateAchievements;
       tempVC=[[UIViewController alloc] init];

       [[UIApplication sharedApplication].keyWindow addSubview:tempVC.view];
       [tempVC presentViewController: gameCenterController animated: YES completion:nil];
    }



 - (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
 {
     [tempVC dismissViewControllerAnimated:YES completion:nil];
     [tempVC.view removeFromSuperview];
     [tempVC release];


     [window becomeFirstResponder];
     [window bringSubviewToFront:gameView];
     [window makeKeyAndVisible];
 }
4

1 回答 1

2

您需要在关闭动画完成后释放游戏中心视图控制器并使主窗口成为第一响应者。这是正确的代码:

- (void)gameCenterViewControllerDidFinish:
(GKGameCenterViewController *)gameCenterViewController {

    [tempVC dismissViewControllerAnimated:YES completion: ^(void) {
        [tempVC.view removeFromSuperview];
        [tempVC release];

        [window becomeFirstResponder];
        [window bringSubviewToFront:gameView.view];
        [window makeKeyAndVisible];
     } ];
}
于 2012-11-27T09:02:07.587 回答