目前我想获取facebook个人资料图片然后将图片转换为CCSprite.
到目前为止我的代码看起来像这样:
//fbId is facebook id of someone
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=normal", fbId]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
//convert UIImage to CCSprite
CCTexture2D *texture = [[[CCTexture2D alloc] initWithImage:image resolutionType:kCCResolutionUnknown] retain];
CCSprite *sprite = [CCSprite spriteWithTexture:texture];
[self addChild:sprite];
Run Code Online (Sandbox Code Playgroud)
它有效,但在加载前需要一段时间,大约几秒钟.
我的问题是,除了互联网连接,有没有更好的方法尽快加载Facebook个人资料图像?谢谢