iOS FBSDKProfilePictureView 返回空白图片
<p><p>所以我试图创建一个用户喜欢的页面的简单滚动条,并显示图像和名称。但是,配置文件 View 显示的是空白图像,而不是占位符图片,这意味着它正在接收要显示的图像。在实际的 FBSDKProfilePictureView 代码中放置一些断点后,特别是在 <code>_updateImageWithData:state:</code> 处,它显示每个图像的数据对象只有 97 个字节。有趣的是,当我创建一个独立的个人资料图片 View 时,比如 </p>
<pre><code> FBSDKProfilePictureView *profilePictureView = [ initWithFrame:CGRectMake(inset, inset, profileSize, profileSize)];
profilePictureView.profileID = @"4"; //Mark Zuckerberg's id
</code></pre>
<p>它可以正确显示图像。 </p>
<p>所以起初我认为这可能与设置太多配置文件 ID 相关,从而创建了太多 url 请求,但如果我只运行下面的代码一次(即没有循环)它仍然返回相同的 97 个字节. </p>
<p>下面是我用来生成 ScrollView 的代码。</p>
<pre><code> for (int i = 0; i < numToIterate; i++) {
NSDictionary *curr = ;
NSString *idNumber = ;
NSString *name = ;
NSLog(@"getting %@, %@.", name, idNumber);
// get logo
FBSDKProfilePictureView *itemView = [ initWithFrame:CGRectMake(i * (smallFrameWidth + horizontalBufferBetweenPics) + horizontalBufferBetweenPics, 0, smallFrameWidth,smallFrameHeight)];
;
;
// create description
UILabel *currDescriptionLabel = [ initWithFrame:CGRectMake(i * (smallFrameWidth + horizontalBufferBetweenPics) + horizontalBufferBetweenPics, smallFrameHeight, categoryLabelWidth, categoryLabelHeight)];
currDescriptionLabel.text = name;
currDescriptionLabel.backgroundColor = [ colorWithAlphaComponent:0.5];
currDescriptionLabel.font = ;
currDescriptionLabel.textAlignment = NSTextAlignmentCenter;
currDescriptionLabel.numberOfLines = 2;
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我创建了一个 <a href="https://github.com/combinatorial/DBFBProfilePictureView" rel="noreferrer noopener nofollow">modified version</a>提供错误报告的 FBProfilePictureView。它允许您设置报告错误的完成处理程序:</p>
<pre><code>self.facebookPictureView.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
if(error) {
view.showEmptyImage = YES;
view.profileID = nil;
NSLog(@"Loading profile picture failed with error: %@", error);
}
}
</code></pre></p>
<p style="font-size: 20px;">关于iOS FBSDKProfilePictureView 返回空白图片,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32448278/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32448278/
</a>
</p>
页:
[1]