gpt4 book ai didi

ios - 从 FBProfilePictureView 快速获取图像

转载 作者:行者123 更新时间:2023-11-28 13:16:08 27 4
gpt4 key购买 nike

用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这是相同的代码,但在 objective-c 中 How can I convert FBProfilePictureView to an UIImage?

最佳答案

你也可以使用替代的想法,

objective-C

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

也改变类型

  • 类型:小号、普通号、大号、方形

swift

 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!)

关于ios - 从 FBProfilePictureView 快速获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28977953/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com