Voglio aggiungere 2 o più celle personalizzate differenti in una Tableview, usando lo storyboard. so come aggiungere celle diffrenti senza storyboard. Lo faccio sempre in questo modo:Come aggiungere diverse celle personalizzate in una TableView con Storyboard?
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//pictureCell = [[DetailPictureCell alloc]init];//(DetailPictureCell *)[tableView dequeueReusableCellWithIdentifier: CellIdentifier];
pictureCell.header = true;
[pictureCell setHeader];
if (cell == nil) {
if ([indexPath row] == 0) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HeaderAngebotViewCell" owner:self options:nil];
NSLog(@"New Header Cell");
}
if([indexPath row] ==1){
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"productCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
E ora la mia domanda: come posso farlo con lo storyboard? Per aggiungere una cella personalizzata è possibile. Ma non posso aggiungere due celle differenti. Mi potete aiutare per favore?
grazie! Puoi pubblicare un esempio come funziona con l'identificativo appropriato in base a percorso dell'indice? –
grazie mille :) –
l'ho fatto come hai detto tu. E ottengo un errore "L'origine dati Tableview deve restituire una cella da tableview: cellforrowatindexpath" Forse ho dimenticato qualcosa? Ho collegato la cella nello storyboard alla cella personalizzata e anche le etichette. ... NSInteger row = [indexPath row]; Riga NSInteger = [riga IndexPath]; Identificatore NSString *; CustomCell * cell = [tableView dequeueReusableCellWithIdentifier: identificatore]; if (row == 0) {identifier = @ "ThirdCell"; cell.clubNameLabel.text = @ "% @", [nome del club objectAtIndex: row]; } cella di restituzione; .... –