J'utilise la méthode qu'Apple montre en utilisant des sous-vues dans le tableau (la plupart de ce qui est ci-dessous vient de leur documentation). Je ne fais qu'entraîner un flux rss d'environ 12 images, mais cela entraîne un défilement lent - si je me débarrasse des images, il se déplace doucement. Les images ne sont pas grandes, ce qui ne peut pas être le problème. Avant d'examiner des solutions plus complexes (traitement en arrière-plan, etc.), y a-t-il quelque chose que je puisse faire pour améliorer ce travail?Défilement saccadé avec seulement quelques images
Merci pour toute aide que vous pouvez donner à ce sujet.
#define MAINLABEL_TAG 1
#define SECONDLABEL_TAG 2
#define PHOTO_TAG 3
-(UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
UILabel * mainLabel, * secondLabel;
UIImageView * photo;
static NSString * CellIdentifier = @ "Cell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(100.0, 0.0, 210.0, 0.0)] autorelease];
mainLabel.tag = MAINLABEL_TAG;
mainLabel.font = [UIFont systemFontOfSize:14.0];
mainLabel.textAlignment = UITextAlignmentRight;
mainLabel.textColor = [UIColor blackColor];
mainLabel.opaque = YES;
mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview : mainLabel];
secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(90.0, 30.0, 220.0, 0.0)] autorelease];
secondLabel.tag = SECONDLABEL_TAG;
secondLabel.font = [UIFont systemFontOfSize:12.0];
secondLabel.textAlignment = UITextAlignmentRight;
secondLabel.textColor = [UIColor darkGrayColor];
secondLabel.opaque = YES;
secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview : secondLabel];
photo = [[[UIImageView alloc] initWithFrame:CGRectMake(30.0, 3.0, 50.0, 40.0)] autorelease];
photo.tag = PHOTO_TAG;
photo.opaque = YES;
photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview : photo];
} else {
mainLabel = (UILabel *)[cell.contentView viewWithTag : MAINLABEL_TAG];
secondLabel = (UILabel *)[cell.contentView viewWithTag : SECONDLABEL_TAG];
photo = (UIImageView *)[cell.contentView viewWithTag : PHOTO_TAG];
}
// Configure the cell.
mainLabel.text = [[items objectAtIndex:indexPath.row] objectForKey:@ "title"];
secondLabel.text = [[items objectAtIndex:indexPath.row] objectForKey:@ "teacher"];
NSString * path = [[items objectAtIndex:indexPath.row] objectForKey:@ "audimage"];
NSString * mypath = [path stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL * url = [NSURL URLWithString:mypath];
NSData * data = [NSData dataWithContentsOfURL:url];
UIImage * img = [[UIImage alloc] initWithData:data];
photo.image = img;
return cell;
[cell release];
}
'[libération cellulaire];' ne sera jamais appelée, comme rien dans une méthode après le retour sera atteint – vikingosegundo