Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason for slow scroll of the table view is that you are trying to get the image data for every cell on the main thread. UI is getting blocked while it is going to fetch the image data from the URL and, According to me its not good to download images on main thread while table view is also loaded.</p> <p>Instead of using this approach, You should have to use NSOperationQueue, NSOperation and NSThread for async load of images to the appropriate cell.</p> <p>If you need more help or simple code like 2-3 function to download images async... </p> <p>Here are the functions....</p> <p>Where you are parsing/getting the values only call [self startLoading]; It will load images without blocking UI.</p> <pre><code>- (void) startLoading { NSOperationQueue *queue = [[[NSOperationQueue alloc]init]autorelease]; NSInvocationOperation *op = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(loadImagesInBackground) object:nil]; [queue addOperation:op]; [op release]; } -(void) loadImagesInBackground { int index = 0; for (NSString urlString in [(Tweet*)[tweetArray objectAtIndex:indexPath.row] image_url]) { NSURL *url = [NSURL URLWithString:urlString]; NSData *data = [[NSData alloc] initWithContentsOfURL:url]; [myImageArray addObject: [UIImage imageWithData:data]]; index++; if(index/3==0) [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if(!cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStyleGrouped reuseIdentifier:nil] autorelease]; UIImageView *myImage = [[UIImageView alloc]initWithFrame:CGRectMake(6,10,58,60)] ; [myImage setImage: [myImageArray objectAtIndex:indexpath.row]]; [cell.contentView addSubview:myImage]; [myImage release]; } return cell; } </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. VO
      singulars
      1. This table or related slice is empty.
    2. 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