ios - custom table cell displaying nil -


i'm trying set title , display button in custom cell object in second table view controller, first dynamic prototype cell displaying text.

the first prototype cell uitableviewcell , second custom object. in first view controller implement same exact method , works fine. not sure error be, models use have data in them. have correct cell identifier in storyboard, , connection custom cell uibutton set.

thanks in advance.

method:

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cellidentifier";     static nsstring *questionsectionidentifier = @"questionsectioncell";      if (indexpath.section == 0)     {         uitableviewcell *cellquestion = [tableview                                          dequeuereusablecellwithidentifier:questionsectionidentifier];         if (cellquestion == nil) {             cellquestion = [[uitableviewcell alloc]                             initwithstyle:uitableviewcellstylesubtitle                             reuseidentifier:questionsectionidentifier];         }         if (indexpath.row == 0) {             cellquestion.textlabel.text = _headerquestion.question;             nslog(@"question here %@", cellquestion.textlabel.text);         }          return cellquestion;     }     else     {         mytableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];         if (cell == nil) {             cell = [[mytableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];         }         if (indexpath.section == 1)         {             if (indexpath.row == 0)             {                 [cell.firstbutton settitle:_headerquestion.questionauthor.fullname forstate:uicontrolstatenormal];                 [cell.firstbutton settag:_headerquestion.questionauthor.userid];                 [cell.answerlabelfield sethidden:yes];                  nslog(@"section 1  %@", cell.firstbutton.titlelabel.text);             }         }         else  if (indexpath.section == 2)         {             answer* answer_num =  [_headerquestion.answers objectatindex:indexpath.row]; //object @ index             [cell.firstbutton settitle:answer_num.answerauthor.fullname forstate:uicontrolstatenormal];             [cell.firstbutton settag:answer_num.answerauthor.userid];             cell.answerlabelfield.text = answer_num.answer;         }         return cell;     } }  -(nsinteger)numberofsectionsintableview:(uitableview *)tableview {     // return number of sections.     return 3; }  -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     if (section == 0)     {         return 1;     }     if (section == 1)     {         return 1;     }     else     {         return [_headerquestion.answers count];     } } 

make sure register both reuse identifiers tableview using

- (void)registerclass:(class nullable)cellclass   forcellreuseidentifier:(nsstring * nonnull)identifier 

or registernib if have nib cell.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -