我有一个与 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
进入我的Viewcontroller
的 UIImageView
我该怎么做。请帮我。 谢谢
最佳答案
如果你有 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/