[英]Facebook iOS SDK FBProfilePictureView not fetching or displaying image
我的View Controller中有以下代碼
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
self.nameString = user.name;
self.profileImage.profileID = [user objectForKey:@"id"];
[self.tableView reloadData];
}
}];
}
我遇到了兩個問題。 首先是永遠不會獲取和顯示個人資料圖像。 第二個是我必須[self.tableView reloadData]
以便顯示名稱。 這會導致難看的滯后。 我該如何解決?
我不知道為什么未提取您的個人資料圖像,但是我遇到了一些無法顯示的個人資料圖像的問題,這導致我編寫了FBProfilePictureView的修改版本,該文件位於此處 。 它有一個完成處理程序,如果下載失敗,則會調用該處理程序並顯示錯誤詳細信息。 (就我而言,我認為問題在於我在短時間內發出了太多請求,但防火牆阻止了其中一些請求)。
至於必須重新加載整個表,則取決於您在何處顯示它。 我假設在牢房里? 如果是這樣,那么在創建單元格時,請執行以下操作:
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
cell.profileImage.profileID = user.id;
}
}];
}
另外,僅需注意,您可以使用user.id
和user.name
來訪問requestForMe
查詢的結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.