Chcę dodać 2 lub więcej różnych niestandardowych komórek w jednym widoku tabeli, używając scenorysów. Wiem, jak dodawać różne komórki bez storyboardu. Zawsze robię to w następujący sposób:Jak dodać różne niestandardowe komórki w jednym widoku tabeli za pomocą scenorysu?
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];
}
A teraz moje pytanie: jak mogę to zrobić przy użyciu storyboardu? Aby dodać jedną komórkę niestandardową, jest to możliwe. Ale nie mogę dodać dwóch różnych komórek. Czy możesz mi pomóc?
dzięki! Można zakładać przykład jak to działa z odpowiednim identyfikatorem indeksu opartego na ścieżce? –
dziękuję bardzo :) –
Zrobiłem to tak, jak powiedziałeś. I pojawia się błąd. "Źródło danych Tableview musi zwracać komórkę z tableview: cellforrowatindexpath" Może coś zapomniałem? Połączyłem komórkę w storybooku z komórką niestandardową, a także z etykietami. ... NSInteger wiersz = [wiersz indexPath]; NSInteger wiersz = [wiersz indexPath]; NSString * identyfikator; CustomCell * cell = [tableView dequeueReusableCellWithIdentifier: identyfikator]; jeśli (wiersz == 0) {identyfikator = @ "ThirdCell"; cell.clubNameLabel.text = @ "% @", [nazwa klubu objectAtIndex: row]; } Zwróć komórkę; .... –