iOS FBSDKProfilePictureView返回空白图像

时间:2015-09-08 02:16:41

标签: ios facebook object facebook-ios-sdk

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

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

正确显示图像。

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

下面是我用来生成滚动视图的代码。

    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];
    }

1 个答案:

答案 0 :(得分:1)

我创建了一个提供错误报告的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);
    } 
}