Posted By

cdnicoll on 06/26/10


Tagged


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

sera
adison
umang_nine
bobbym245
sb
nsbuckner
cnathan


Load Image From URL


 / Published in: Objective C
 

  1. // NOTE: this uses place holders.
  2. // PART 1 - update url of path to the image
  3. // PART 2 - update the variable reference to the UIImageView object
  4. // -----------------------------------------------
  5.  
  6. // ===== PART 1 =====
  7. UIImage *imgURL = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"${part 1 image path:http://www.example.com/img.jpg}"]]] retain];
  8.  
  9. if (imgURL != nil) { // Image was loaded successfully.
  10. // ===== PART 2 =====
  11. [${part 2 UIImageView Ref:myMainImg} setImage:imgURL];
  12. // ===== PART 2 =====
  13. [${part 2 UIImageView Ref:myMainImg} setUserInteractionEnabled:NO];
  14. [imgURL release]; // Release the image now that we have a UIImageView that contains it.
  15. }

Report this snippet  

You need to login to post a comment.