FBProfilePictureView is not showing image

279 views Asked by At

I'm having the same problem I saw some people have with the FBProfilePictureView not showing the photo. I've already seen this question and I've added

[FBProfilePictureView class];

to my first line of the app delegate method didFinishLaunching but that did not solve.

Sometimes it loads all images, sometimes it loads most of them and sometimes only a few images.

I create the FBProfilePictureView programmatically doing:

FBProfilePictureView *friendProfilePic = [[FBProfilePictureView alloc] init];

friendProfilePic.profileID = friendID; //friendID is a NSString I've created before

friendProfilePic.frame = CGRectMake(xPos, yPos, width, height);

Does anyone know what might be happening?

Note: I didn't want to use -ObjC linker flag because it will raise my app size

Note2: I can't comment on questions so I had to make another one.

Thanks

2

There are 2 answers

2
combinatorial On

If it is loading some images then it is not related to the ObjC linker flag. It is likely some of the requests are failing. I created a replacement for FBProfilePictureView that reports errors. Add it to your project and change your code to:

DBFBProfilePictureView *friendProfilePic = [[DBFBProfilePictureView alloc] initWithFrame:CGRectMake(xPos, yPos, width, height)];
friendProfilePic.profileID = friendID;
friendProfilePic.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
        if(error) {
            view.showEmptyImage = YES;
            view.profileID = nil;
            NSLog(@"Loading profile picture failed with error: %@", error);
        } 
    };

and you will see any errors logged to the console.

0
gdbj On

Did you add the ProfilePic to your view?

Get the main view, and add the profilepic as a subview to it.

[myMainView addSubView: friendProfilePic]