I have a tableview with about 20 cells with images that are downloaded from the net.
Right now it is choppy when scrolling and it needs to be make more smooth.
My method is:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
break;
}
}
}
NSDictionary *article = [entriesArray objectAtIndex:[indexPath row]];
NSString *title = [article objectForKey:@"title"];
NSString *date = [article objectForKey:@"publishedDate"];
NSString *dateEdited = [date substringToIndex:16];
cell.nameLabel.text = title;
cell.dateLabel.text = dateEdited;
NSURL *myURL=[NSURL URLWithString:[self.picturesArray objectAtIndex:indexPath.row]];
NSData *myData1 = [[NSData alloc] initWithContentsOfURL:myURL];
UIImage *myImage = [[UIImage alloc] initWithData:myData1];
cell.imageView.image = myImage;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 2;
return cell;
}
Any advice?