ios - 如何将FBProfile图片获取到UIImageView中

标签 ios facebook

我有一个与 FBLoging 集成的 iOS 应用程序。我知道它可以将个人资料图片分配给 UIView像这样。

// This method will be called when the user information has been fetched - (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user { self.profilePictureView.profileID = user.id; }

但我想做的是将个人资料图片放入我已经可用的 UIImageView .为了做到这一点,我有一个单例类。我想将该图像作为 UIImage并分配给该 Singleton 类中的变量。当另一个Viewcontroller load 我想分配那个单例类的 UIImage进入我的ViewcontrollerUIImageView

我该怎么做。请帮我。 谢谢

最佳答案

如果你有 Facebook user.id,你可以像这样创建 imageURL

   NSString * url = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large",user.objectID];

然后将此 url 保存到您的单例类中。如果需要,您可以这样下载。(您可以每次下载或下载一次并保存到文件中,如果需要,从文件中获取)。

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
UIImage *userImage = [UIImage imageWithData:data];

关于ios - 如何将FBProfile图片获取到UIImageView中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24566474/

相关文章:

javascript - 自定义 facebook 之类的链接?

javascript - FB Api - 喜欢显示内容

objective-c - 将 NSString 写入文件

iphone - 是否可以将 UITapGestureRecognizer 附加到 UILabel 子类

ios - 在 iOS 中集成 FCM 以进行推送通知时,是否使用了 Device Token?

java - 如何使用 facebook 登录并获取用户信息以从 android 应用程序发送我的远程数据库

php - Laravel 社交名媛 Facebook 错误 : "POST https://graph.facebook.com/oauth/access_token resulted in a ` 400 Bad Request` "

ios - SKLabelNode labelNodeWithFontNamed:

ios - 检查有效的希伯来语正则表达式总是返回 YES

ios - 如何在 IOS 中使用 Facebook URL Schemes