簡體   English   中英

如何使用Facebook SDK保存從fbprofilepictureview獲取的用戶圖像

[英]How Do I save the user's image fetched from fbprofilepictureview using the Facebook SDK

因此,我正在當前正在使用的iOS應用中實現Facebook登錄按鈕,我試圖保存使用此行訪問的用戶個人資料圖片;

self.profilePicture.profileID = user.id;

我沒有運氣將該圖像存儲在應用程序的其他位置。 我嘗試了許多方法,包括這種方法

imageUrl=[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?redirect=true", user.username];

歡迎任何幫助!

您需要使用user.objectID而不是user.username

您也可以使用FBProfilePictureView的直接替代品DBFBProfilePictureView 這會將imageView公開為只讀屬性。 使用它,您的代碼將是這樣的……

self.profilePicture.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
    if(error) {
        view.showEmptyImage = YES;
        NSLog(@"Loading profile picture failed with error: %@", error);
    } else {
        UIImage *image = view.imageView.image;
        NSData *imageData = UIImagePNGRepresentation(image);
        [imageData writeToFile:filename atomically:NO];
    }
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM