I am working on Game Center for iOS devices using the sandbox environment. I am trying to load the achievement images I set up in iTunes Connect.

I am using loadAchievementDescriptionWithConpletionHandler successfully.

The problem happens when I try to load the image using loadImageWithCompletionHandler.

[self.description loadImageWithCompletionHandler:^(UIImage *image, NSError *error) {
     if (!error) {
          self.achievementImage = image;
     }
 }];

The problem is both the UIImage and the error are nil. It is due to the sandbox environment ? Am I missing something ?

Thanks

有帮助吗?

解决方案

I can load the image successfully. It looks like my image format was wrong.

I have deleted the achievement and created a new one using a 512x512 72 dpi image.

Using loadAchievementDescriptionsWithCompletionHandler. I load all the achievementDescriptions from Game Center. Then, I use loadImageWithCompletionHandler to extract the image.

[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) {
    if (!error) {
        for (GKAchievementDescription *achievementDescription in descriptions) {
            [self.achievementDescriptionDictionary setObject:achievementDescription
                                                      forKey:achievementDescription.identifier];

            [achievementDescription loadImageWithCompletionHandler:^(UIImage *image, NSError *error) {
                if (!error) {
                    if (image) {
                        UIImage *achievementimage = image;
                    }
                }
            }];
        }
    }
}];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top