简体   繁体   中英

iOS FBSDKProfilePictureView returning blank image

So I'm trying to create a simple scrolling bar of pages a user likes, with the image and name displayed. However, the profile view shows a blank image, not a placeholder picture, which means that it's receiving an image to display. After placing some break points in the actual FBSDKProfilePictureView code, specifically at _updateImageWithData:state: , it's showing that for each image the data object is only 97 bytes. The funny thing is, when I so something like create a standalone profile picture view, like

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

it displays the image properly.

So at first I thought it might have been something to do with setting too many profile ids, thus creating too many url requests, but if I just ran the code below once (ie no loop) it still returns the same 97 bytes.

Below is the code I use to generate the scroll view.

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

I created a modified version of FBProfilePictureView that provides error reporting. It allows you to set a completion handler where errors are reported:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM