iphone - Asynchronous loading of images -


i have loaded images please tell me how use asynchrounous loading of images

make use of egoimageview assuming want display downloaded image in uiimageview, it's easy (just initialize placeholder image , set url of image download).

http://developers.enormego.com/view/what_if_images_on_the_iphone_were_as_easy_as_html

if don't want display image, want asynchronous downloading, make use of egoimageloader.

just make sure class conforms egoimageloaderobserver protocol , implement 2 delegate methods , you're done ...

- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self)      {        imageloader = [egoimageloader sharedimageloader]; // ivar, can remove observer in dealloc ...     }     return self; }  - (void)dealloc {    [imageloader removeobserver:self];    [super dealloc]; }  - (void)viewdidload {    [super viewdidload];     nsstring *urlstring = @"http://www.wimwauters.be/wp-content/uploads/2011/01/steve-jobs.jpg";    nsurl *url = [nsurl urlwithstring:urlstring];    [imageloader loadimageforurl:url observer:self];             }  #pragma mark - egoimageloaderobserver  - (void)imageloaderdidload:(nsnotification*)notification  {    nsdictionary *userinfo = [notification userinfo];    uiimage *theimage = [userinfo objectforkey:@"image"];     // image, e.g. display in imageview ... }  - (void)imageloaderdidfailtoload:(nsnotification*)notification  {    nsdictionary *userinfo = [notification userinfo];    nserror *error = [userinfo objectforkey:@"error"];    if (error)     {     // handle error    } } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -