How can I convert FBProfilePictureView to an UIImage?

FBProfilePictureView is a UIView, this UIView contains a UIImageView, that is your image, you can get the UIImage from that UIImageView:

profilePictureView is a FBProfilePictureView

UIImage *image = nil;

for (NSObject *obj in [profilePictureView subviews]) {
    if ([obj isMemberOfClass:[UIImageView class]]) {
        UIImageView *objImg = (UIImageView *)obj;
        image = objImg.image;
        break;
    }
}

EDIT: add another way more quickly but do the same thing

__block UIImage *image = nil;

[self.view.subviews enumerateObjectsUsingBlock:^(NSObject *obj, NSUInteger idx, BOOL *stop) {
    if ([obj isMemberOfClass:[UIImageView class]]) {
        UIImageView *objImg = (UIImageView *)obj;
        image = objImg.image;
        *stop = YES;
    }
}];

Leave a Comment