Best practices for managing facebook friends pics

2020-06-06 08:07发布

问题:

i'm working on an iOS app which has a tableview containing facebook friends' list, I want to manage this list for scrolling performance.

i don't want to load the images each time user open that friend list view, and for that images can be saved locally but at the same time it would not be a good practice as users can change their profile pictures after we already saved older ones to file system.

So i just wondering what is the best way to manage this?

Also how can i get those images in best possible optimized size?

thanks in advance

回答1:

You might be able to use setImageWithURL:placeholderImage: in the UIImageView class in AFNetworking to load a placeholder (or existing image) and then request the latest image which will get updated when fetched.

The docs are here:

http://afnetworking.org/Documentation/Categories/UIImageView+AFNetworking.html

The project is here:

https://github.com/AFNetworking/AFNetworking/

UIImageView should take care of resizing the images.



回答2:

Well if you want to set placeholder image it is possible. The FBProfilePictureView is a UIView but if take a look into the code you'll see that they add UIImageView to it. That's why you can use:

for (UIView *view in cell.faceImageView.subviews) {
    if ([view isKindOfClass:[UIImageView class]]) {
        [(UIImageView*)view setImage:[UIImage imageNamed:@"placeholder"]];
        break;
    }
}

Ofc, that's a workaround. However until they provide better thing you don't have to mess here with AFNetworking(which is a great lib btw) and finding facebook image url ;).