Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Give ASIHTTPRequest a try, just maybe loading image asynchrony in the background can improve speed when loading several images at the same time, checkout ASINetworkQueue</p> <p>Didn't try it but here it is:</p> <pre><code>#import "ASIHTTPRequest.h" #import "ASINetworkQueue.h" -(void)loadImages { ASINetworkQueue * asiNetworkQueue = [ASINetworkQueue queue]; [asiNetworkQueue setDelegate:self]; [asiNetworkQueue setShouldCancelAllRequestsOnFailure:NO]; for(int i=0; i &lt; 20; i++) { NSURL *url = [NSURL URLWithString:@"some_url"]; ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; [request setDidFinishSelector:@selector(imageRequestFinished:)]; [request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:i] forKey:@"id"]]; } [asiNetworkQueue go]; } -(void)imageRequestFinished:(ASIHTTPRequest *)request { UIImage* image = [UIImage imageWithData:[request responseData]]; //Use the id to match the request with a specific UIImageView int imageId = [request.userInfo objectForKey:@"id"]; //imageViewArray[imageId].image = image; } </code></pre> <p>//------------------------------------ EDIT - Loading a single image //------------------------------------</p> <pre><code>-(void)loadImage:(NSString*)imagePath { //_activityIndicator.hidden = FALSE; //[_activityIndicator startAnimating]; NSURL*imageURL = [NSURL URLWithString:imagePath]; ASIHTTPRequest* request = [[[ASIHTTPRequest alloc] initWithURL:imageURL] autorelease]; [request setDidFailSelector:@selector(requestDidFailed:)]; [request setDidStartSelector:@selector(requestDidStarted:)]; [request setDidFinishSelector:@selector(requestDidFinished:)]; [request setDelegate:self]; [request startAsynchronous]; } - (void)requestDidFinished:(ASIHTTPRequest *)request { //_activityIndicator.hidden = TRUE; //[_activityIndicator stopAnimating]; self.imageView.image = [UIImage imageWithData:[request responseData]]; // NSLog(@"image download finished"); } - (void)requestDidFailed:(ASIHTTPRequest *)request { NSError *error = [request error]; //NSLog(@"Loading Image Failed"); //_activityIndicator.hidden = TRUE; //[_activityIndicator stopAnimating]; } - (void)requestDidStarted:(ASIHTTPRequest *)request { //NSLog(@"image download started"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload