小编use*_*616的帖子

获取facebook个人资料图片

目前我想获取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个人资料图像?谢谢

objective-c cocos2d-iphone ios ccsprite

3
推荐指数
1
解决办法
2313
查看次数

标签 统计

ccsprite ×1

cocos2d-iphone ×1

ios ×1

objective-c ×1