Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad images in to a ScrollView
    primarykey
    data
    text
    <p>Hi have a problem with that load images (1024x1024) cached on disk to a UIScrollView takes a while (just a lagg but annoing) to load into memory. when a use images with size 668px × 445px the lagg is acceptable. I have tried to Load the data using threads same result when I use dispatch_async</p> <p>Any ide how to improve preformance on loading data async?</p> <pre><code>-(void)setupImageView:(BMPhoto *)_photo { methodStart = [[NSDate date] retain]; if ([[photo imageUrl] isEqualToString:[_photo imageUrl]]) return; photo = _photo; [imageView removeFromSuperview]; [imageView release]; imageView = nil; self.zoomScale = 1.0; BMCache *cache = [BMCache sharedCache]; if ([cache isFileCached:[photo imageUrl]]) { [NSThread detachNewThreadSelector:@selector(loadImageFromCache:) toTarget:self withObject:[photo imageUrl]]; } else { [NSThread detachNewThreadSelector:@selector(loadImageFrom:) toTarget:self withObject:[photo imageUrl]]; } } -(void)loadImageFromCache:(NSString *)url{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIImage *image = [UIImage imageWithData:[[BMCache sharedCache] getCachedRemoteFile:url]]; [self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO]; [pool release]; } -(void)loadImageFrom:(NSString *)url{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[photo imageUrl]]]; [[BMCache sharedCache] addRemoteFileToCache:url withData:imageData]; UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease]; [imageData release]; [self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO]; [pool release]; } - (void)displayImage:(UIImage *)image { NSDate *methodFinish1 = [NSDate date]; NSTimeInterval executionTime1 = [methodFinish1 timeIntervalSinceDate:methodStart]; NSLog(@"Thread Done time: %f", executionTime1); if (image) { //imageView.image = nil; imageView = [[BMPhotoViewImageView alloc] initWithImage:image]; [self addSubview:imageView]; self.contentSize = [image size]; [self setMaxMinZoomScalesForCurrentBounds]; self.zoomScale = self.minimumZoomScale; NSTimeInterval executionTime2 = [[NSDate date] timeIntervalSinceDate:methodFinish1]; NSLog(@"Load image time time: %f", executionTime2); NSDate *methodFinish = [NSDate date]; NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart]; NSLog(@"Total time: %f", executionTime); NSLog(@"-------------------------------------------"); } } </code></pre> <p>Thread Done time: 0.015229 Load image time time: 0.009824</p> <h2>Total time: 0.028263</h2> <p>Thread Done time: 0.025037 Load image time time: 0.005314</p> <h2>Total time: 0.035781</h2> <p>Thread Done time: 0.026063 Load image time time: 0.004379</p> <h2>Total time: 0.033177</h2>
    singulars
    1. This table or related slice is empty.
    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.
 

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