title: Load Large image asynchronously into photo album like view
body: <p>I'm trying to make view like photo album. but image file is quite big (2048x1536, png). It takes quite time to load several images. So made thread for loading images..
  At first..make UIButton for image holder.</p>
  
  <pre><code>UIButton* thumbnail = [[UIButton alloc] initWithFrame:r];
  [[self scroll] addSubview:thumbnail];
  [thumbnail release];
  </code></pre>
  
  <p>and start thread for image loading</p>
  
  <pre><code>[NSThread detachNewThreadSelector:@selector(th_load_filelist) toTarget:self withObject:nil];
  </code></pre>
  
  <p>thread is here</p>
  
  <pre><code>-(void) th_load_filelist
  {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];    
     for (UIButton* bt in [self.scroll subviews])
     {
        UIImage* img = [[UIImage alloc] initWithContentsOfFile:(NSString*)bt.tag];
        [[bt layer] performSelectorOnMainThread:@selector(setContents:) withObject:(id)[img CGImage] waitUntilDone:YES];
        [img release];
     }
  
     [pool release];
  }
  </code></pre>
  
  <p>It works well. in normal situation.
  But If there are many images and memory warning happends.
  App is crashed without any error message.
  Could you give me tip to fix it ?
  I suspect there is memory problem caused by large images..</p>