使用fb登录时,以下UIView将显示用户配置文件图片
@IBOutlet var profilePictureView : FBProfilePictureView
如何获取图像以便在其他地方使用/保存到服务器?
以下是FBProfilePictureView的fb文档(在Objective-C中)https://developers.facebook.com/docs/reference/ios/current/class/FBProfilePictureView
这是fb登录的快速端口,工作正常。
https://www.snip2code.com/Snippet/68653/This-is-a-swift-port-of-the-official-Fac
这里有相同的代码,但是在目标C中
How can I convert FBProfilePictureView to an UIImage?
最佳答案
你也可以换个主意,
目标C
NSString *userImageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", [FBuser objectID]];
同时更改类型
类型:小型、普通、大型、方形
斯威夫特
let avatar = "https://graph.facebook.com/\(user.objectID)/picture?width=640&height=640"
或者另一个选择
let url = NSURL.URLWithString("https://graph.facebook.com/\(user.objectID)/picture?width=640&height=640");
let data = NSData(contentsOfURL: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check
yourimagename.image = UIImage(data: data!)