Load Image From URL


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.