简体   繁体   中英

FBProfilePictureView is not showing image

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

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.

Did you add the ProfilePic to your view?

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

[myMainView addSubView: friendProfilePic]

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