Ho realizzato una tableview con un cella custom tramite uno XIB in cui ho posizionato delle labels e un paio di immagini.
Poi ho dichiarato nel file .h questo IBOutlet
@property (strong, nonatomic) IBOutlet UITableViewCell *nibLoadedTableCell;
Ed in .m questa porzione crea la tableview con la cella personalizzata:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
////////////////////////////////////////////////////////////////////////
// UTILIZZO DI UNA CELLA PERSONALIZZATA CON UNO XIB //
////////////////////////////////////////////////////////////////////////
//dichiaro la cella personalizzata e carico lo xib
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:@"Labeltv"];
if (myCell == nil) {
/*
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"Labeltv" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
myCell = [topLevelObjects objectAtIndex:0];
*/
[[NSBundle mainBundle] loadNibNamed:@"Labeltv" owner:self options:nil];
myCell = nibLoadedTableCell;
//GET ITEMS
item = [entryArray objectAtIndex:indexPath.row];
//con questa dichiarazione riesco a puntare le label nella cella xib personalizzata
UILabel *label = (UILabel *) [myCell viewWithTag:1];
UILabel *label1 = (UILabel *) [myCell viewWithTag:2];
UILabel *label2 = (UILabel *) [myCell viewWithTag:3];
label.text = item.titolo;
label1.text = item.data;
label2.text = item.descrizione;
NSString *link;
link = [item.urlImage stringByReplacingOccurrencesOfString:@" " withString:@""];
link = [link stringByReplacingOccurrencesOfString:@"
" withString:@""];
link = [link stringByReplacingOccurrencesOfString:@" " withString:@""];
NSURL * imageURL = [NSURL URLWithString:link];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];
//[[cell imageView] setImage:image];
[[myCell imageView] setImage:image];
}
//return Cell;
return myCell;
}
Ora ho un problema, quando scorro la tableview le celle si inceppano e ci mettono un po’ a muoversi fluidamente.
Cosa potrebbe essere? Tenete conto che ho fatto un parser di un XML remoto da cui prendo le informazioni per l’url dell’immagine, e i dati delle labels.
Potrebbe essere un problema di connessione?