Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone Simulator 6.0无法在沙盒模式下连接到gamecenter_Iphone_Ios_Ios6_Ios Simulator_Game Center - Fatal编程技术网

iPhone Simulator 6.0无法在沙盒模式下连接到gamecenter

iPhone Simulator 6.0无法在沙盒模式下连接到gamecenter,iphone,ios,ios6,ios-simulator,game-center,Iphone,Ios,Ios6,Ios Simulator,Game Center,我正在尝试实现一个针对iOS 6的gamecenter感知应用程序。为了提供一些关于环境的信息,我正在使用MacOS10.7.5,XCode版本是4.5.2,XCode运行的是iphone和ipad模拟器版本6.0。问题是我无法通过ipad或iphone模拟器以沙箱模式连接到gamecenter,但在我的iphone上测试时,相同的代码可以按预期工作 我遵循苹果开发者库中的gamecenter编程指南,从appdelegate中的ApplicationIDFinishLaunching中获得了这

我正在尝试实现一个针对iOS 6的gamecenter感知应用程序。为了提供一些关于环境的信息,我正在使用MacOS10.7.5,XCode版本是4.5.2,XCode运行的是iphone和ipad模拟器版本6.0。问题是我无法通过ipad或iphone模拟器以沙箱模式连接到gamecenter,但在我的iphone上测试时,相同的代码可以按预期工作

我遵循苹果开发者库中的gamecenter编程指南,从appdelegate中的ApplicationIDFinishLaunching中获得了这个atm:

- (void)authenticateLocalUser:(UIViewController *)currentViewController
{

    if (!gameCenterAvailable) return;
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){

        if (viewController != nil)
        {
            [currentViewController presentViewController:viewController animated:YES completion:nil];

        }
        else if (localPlayer.isAuthenticated)
        {
            NSLog(@"Player authenticated");
        }
        else
        {
            NSLog(@"Player not authenticated");
        }
        NSLog(@"Error: %@",error);
    };
}
它输出:

Error: Error Domain=GKErrorDomain Code=2 "The requested operation has been cancelled."
UserInfo=0x8690510 {NSLocalizedDescription=The requested operation has been cancelled.}

GKSConnSettings: set server: {
        "gk-cdx" = "17.173.254.218:4398";
        "gk-commnat-cohort" = "17.173.254.220:16386";
        "gk-commnat-main0" = "17.173.254.219:16384";
        "gk-commnat-main1" = "17.173.254.219:16385";
    }
虽然我的操作系统不是10.8.2,但我已经尝试了主机文件修复,但没有任何帮助

知道可能的原因是什么吗


编辑:事实证明,以GKSConnSettings开头的输出部分并不表示存在任何问题,这是连接到游戏中心时的常规输出,正如我在互联网上看到的那样。我在身份验证块中打印了实际的错误消息(gkerrodomain=2…)。

我从:,得到了灵感,并决定使用另一段代码登录到游戏中心帐户。所以在viewdidload中,我通常调用:

[[GCHelper sharedInstance] authenticateLocalUser:self];
现在我发表了评论,通过下面的URL方案访问游戏中心,登录到我的帐户,然后注销

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];

最后,通过注释出URL代码并使用原始代码恢复。现在它工作正常了,我想问题是游戏中心的帐户已经连接到模拟器上了,它拒绝了所有的登录请求。希望苹果在错误信息方面能更清楚,它花了一个月的时间解决了这样一个简单的问题,希望这对其他人有所帮助。

我知道这个问题涉及特定的Xcode和iOS模拟版本,但是如果你的模拟器已经登录到一个帐户,你不介意丢失模拟器上的任何数据(机会很小,但你永远不知道),你可以简单地重置设置和数据

转到: 模拟器->重置内容和设置

…并在出现提示时确认操作

对于运行iOS9.x模拟器的Xcode7.x来说,这当然是正确的,其他人可能能够验证它是否适用于早期版本(特别是我发现了一个非常古老的问题和答案)

动物451 坏死性线状瘤:+1