-1

I have an array of 5 strings that are URLs of logos I'd like to populate cells. The URLs are taken after a searchBarSearchButtonClicked gets these URLs from a JSON response which then populates the arrays.

I have tried a different bunch of tutorials which takes URLs into UIImages to no avail. Also, I'd like to know if this is the right technique to use?

Robotic Cat
  • 5,899
  • 4
  • 41
  • 58
fadfad
  • 349
  • 1
  • 5
  • 17
  • To be honest, I've tried a bunch of things I don't really understand. Just a bunch of tutorials on how to download images asynchronously and none to no avail. – fadfad Feb 06 '15 at 16:39
  • Also the UIImageView's exist inside UITableViewCell's. – fadfad Feb 06 '15 at 16:39

3 Answers3

1

My suggestion would be https://github.com/nicklockwood/AsyncImageView

    AsyncImageView *imageViewDisplay = [[AsyncImageView alloc] initWithFrame:someFrame];
        imageViewDisplay.contentMode = UIViewContentModeScaleAspectFit;
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(imageLoaded:)
                                                     name:AsyncImageLoadDidFinish
                                                   object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(imageLoadFailed:)
                                                     name:AsyncImageLoadDidFail
                                                   object:nil];
        imageViewDisplay.imageURL = myImageURL;

Works like a charm and I have been using it.

riyaz
  • 1,093
  • 1
  • 8
  • 21
  • Do you know if they have a Swift version or any similar library? – fadfad Feb 06 '15 at 16:49
  • Not a big deal. You can always import obj c classes in swift projects and you can use it. Have a look at it http://stackoverflow.com/questions/24002369/how-to-call-objective-c-code-from-swift – riyaz Feb 06 '15 at 16:59
  • Give me an UP if you find it useful. – riyaz Feb 06 '15 at 17:00
0

Give PHImageManager a try, as you can load images from a URL asynchronously. NSHipster has an article that walks through loading images into a UITableView.

timgcarlson
  • 3,017
  • 25
  • 52
0

The basic premise is that you use the URL to fetch the image data (NSData), you make a UIImage with the image data, and you then assign this UIImage to a UIImageView in order to display it. In your case, this UIImageView would be embedded within a UITableViewCell. Is this the process you are following? If so, it would be helpful to know where the process is breaking down (i.e. if the data is nil, if the image is nil, or if it's just the image view which doesn't show the image.

Jose
  • 106
  • 4