• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iOS FBSDKProfilePictureView 返回空白图片

[复制链接]
菜鸟教程小白 发表于 2022-12-13 10:35:00 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

所以我试图创建一个用户喜欢的页面的简单滚动条,并显示图像和名称。但是,配置文件 View 显示的是空白图像,而不是占位符图片,这意味着它正在接收要显示的图像。在实际的 FBSDKProfilePictureView 代码中放置一些断点后,特别是在 _updateImageWithData:state: 处,它显示每个图像的数据对象只有 97 个字节。有趣的是,当我创建一个独立的个人资料图片 View 时,比如

    FBSDKProfilePictureView *profilePictureView = [[FBSDKProfilePictureView alloc] initWithFrame:CGRectMake(inset, inset, profileSize, profileSize)];
    profilePictureView.profileID = @"4"; //Mark Zuckerberg's id

它可以正确显示图像。

所以起初我认为这可能与设置太多配置文件 ID 相关,从而创建了太多 url 请求,但如果我只运行下面的代码一次(即没有循环)它仍然返回相同的 97 个字节.

下面是我用来生成 ScrollView 的代码。

    for (int i = 0; i < numToIterate; i++) {
        NSDictionary *curr = [sharedInterests objectAtIndex:i];
        NSString *idNumber = [curr objectForKey"id"];
        NSString *name = [curr objectForKey"name"];
        NSLog(@"getting %@, %@.", name, idNumber);
        // get logo
        FBSDKProfilePictureView *itemView = [[FBSDKProfilePictureView alloc] initWithFrame:CGRectMake(i * (smallFrameWidth + horizontalBufferBetweenPics) + horizontalBufferBetweenPics, 0, smallFrameWidth,smallFrameHeight)];
        [self.scrollView addSubview:itemView];
        [itemView setProfileID:idNumber];
        // create description
        UILabel *currDescriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(i * (smallFrameWidth + horizontalBufferBetweenPics) + horizontalBufferBetweenPics, smallFrameHeight, categoryLabelWidth, categoryLabelHeight)];
        currDescriptionLabel.text = name;
        currDescriptionLabel.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
        currDescriptionLabel.font = [UIFont fontWithName"HelveticaNeue-Light" size:12];
        currDescriptionLabel.textAlignment = NSTextAlignmentCenter;
        currDescriptionLabel.numberOfLines = 2;
        [scrollView addSubview:currDescriptionLabel];
    }



Best Answer-推荐答案


我创建了一个 modified version提供错误报告的 FBProfilePictureView。它允许您设置报告错误的完成处理程序:

self.facebookPictureView.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
    if(error) {
        view.showEmptyImage = YES;
        view.profileID = nil;
        NSLog(@"Loading profile picture failed with error: %@", error);
    } 
}

关于iOS FBSDKProfilePictureView 返回空白图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32448278/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap