Я пытаюсь установить заголовок и отобразить кнопку в своем пользовательском объекте ячейки во втором контроллере табличного представления, но текст отображается только в моей первой динамической ячейке-прототипе.
Первая ячейка-прототип — UITableViewCell, а вторая — пользовательский объект. В моем первом контроллере представления я реализую почти такой же точный метод, и он отлично работает. Не уверен, в чем может быть моя ошибка, модели, которые я использую, содержат все свои данные. У меня есть правильный идентификатор ячейки в моей раскадровке, и установлено соединение из пользовательской ячейки с UIButton.
Заранее спасибо.
Метод:
-(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 at 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 the 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];
}
}
cell
?cell.firstButton
? - person Larme   schedule 25.06.2015tableView(_:cellForRowAtIndexPath:)
звонят? - person ndmeiri   schedule 25.06.2015- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
?... какой у васcell
? :) - person Yuyutsu   schedule 25.06.2015