- (void)gameCenterViewControllerDidFinish :( GKGameCenterViewController *)gameCenterViewController未被调用

时间:2014-12-26 13:36:46

标签: ios objective-c dismiss

在标题中,我没有设法调用该回调,以便在iOS 7 iPhone和iOS 8 iPad上都不关闭游戏中心视图控制器。这是我使用的代码:

GKGameCenterViewController *controller=nil;

- (IBAction)achievementButtonClicked:(id)sender {
    if (!controller){
        controller=[[GKGameCenterViewController alloc] init];
        controller.delegate=self;
    }
    NSLog(@"controller=%@", controller);
    if (controller) [self presentViewController:controller animated:YES completion:nil];
}

-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController{
    [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];

   // I also tried [self dismissViewControllerAnimated:YES completion:nil] but anyway the function seems to not even enter here
}

如果我关闭该功能,代表会投诉它丢失,所以问题不应该与之相关。可能是什么以及如何解决它?

1 个答案:

答案 0 :(得分:0)

我的问题是我用过:

    controller.delegate=self;

遗漏:

    controller.gameCenterDelegate = self;

一旦插入后者,视图控制器就会毫无问题地解散,当我手动呈现控制器以及何时显示登录她时。我真的很想知道为什么那个野兽太过代表,如果不是为了让开发人员感到困惑......