的tutorial說我應該使用: FBProfilePictureView我們可以只使用正常的imageView的臉譜照片?
好了,說我想用普通的ImageView,然後下載圖像URL。我將如何獲得該imageURL?
的tutorial說我應該使用: FBProfilePictureView我們可以只使用正常的imageView的臉譜照片?
好了,說我想用普通的ImageView,然後下載圖像URL。我將如何獲得該imageURL?
以下代碼直接從FBProfilePictureView
實現中獲取。我只保留了基本的東西,允許您下載個人資料圖片並將其存儲在普通的UIImageView
中。
#import "FBURLConnection.h"
#import "FBRequest.h"
//...
UIImageView * imageView = nil;
NSString * profileID = @"123456"; // the profile ID of the user you need to retrieve the image of;
FBURLConnectionHandler handler = ^(FBURLConnection *connection, NSError *error, NSURLResponse *response, NSData *data) {
if (!error) {
imageView.image = [UIImage imageWithData:data];
}
};
NSString *template = @"%@/%@/picture";
NSString *urlString = [NSString stringWithFormat:template,
FBGraphBasePath,
profileID];
NSURL *url = [NSURL URLWithString:urlString];
[[FBURLConnection alloc] initWithURL:url
completionHandler:handler];
不過我覺得FBProfilePictureView
的方式比使用普通UIImageView
更方便。你爲什麼不想用它?
因爲我已經實現了一個ImageView類的緩存和東西。 –
另外我用你的解決方案。我只是要求更大的圖片。 –
它的工作:)謝謝。 –
我假設你想得到用戶的個人資料圖片。
您可以獲取來自Facebook OpenGraph用戶API調用的網址:https://developers.facebook.com/docs/reference/api/user/
看picture
屬性。
這很好。我正在尋找使用IOS API的東西。 –
有一點上下文會有所幫助。你首先在談論什麼教程? –
補充說。好吧,爲什麼這不是一個真正的問題,因爲我得到了一個非常好的答案,我真的使用了 –