0

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
    If you're lucky, the profile picture URL changes if the profile picture is edited. See what happens when you make changes, especially if you change the bit that gets cropped into the profile pic. It's unlikely that they'll serve one of exactly the right size; you may be able to append "_t" for the thumbnail image though (but check that this is big enough on retina displays!). – tc. Jul 20 '12 at 22:20

2 Answers2

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.

nuxibyte
  • 1,434
  • 1
  • 13
  • 16
1

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 ;).

Nat
  • 12,032
  • 9
  • 56
  • 103