我通过在函数中使用以下代码递归地在自定义排行榜中加载照片:
-(void)loadPhotos {
[((GKPlayer*)[players objectAtIndex:i]) loadPhotoForSize:GKPhotoSizeSmall withCompletionHandler: ^(UIImage *photo, NSError *error) {
if (error != nil)
{
NSLog(@"Error: %@", error);
}
if (photo != nil)
{
[friendPhotos addObject:photo];
[globalTable reloadData];
i++;
if (i< [players count]){
[self loadPhotos];
}
}
}];
}
我们目前正在两台设备上测试该应用程序,因此我们的沙盒环境中有 2 名玩家。然而,第一个播放器的第一个调用加载了照片,但第二个照片,我无法加载,并且打印了以下错误:
Error: Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=0x1b19f0 {NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}
有什么建议吗?
附言。还在循环中反复尝试。同样的错误,我认为这是因为我打电话太频繁了。
最佳答案
此类错误的一个可能原因是您没有启用正确的端口转发。参见 this Apple doc .
关于iphone - Game Center 无法加载多个玩家 ID 的照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8451844/