AutoLayout в UITableview с динамической высотой ячейки

Для динамической высоты моей ячейки табличного представления я беру ссылку из этой ссылки.Использование Auto Layout в UITableView для динамического размещения ячеек и переменной высоты строк

Вот мой код источника данных tableview и методов делегата

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
  {
       return arrTemp. count;
  }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"AutoLAyoutCell";

AutoLayoutTableViewCell *cell=(AutoLayoutTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
    for (id currentObject in [[NSBundle mainBundle] loadNibNamed:@"AutoLayoutTableViewCell" owner:self options:nil]) {
        if ([currentObject isKindOfClass:[UITableViewCell class]]) {
            cell = (AutoLayoutTableViewCell *)currentObject;
            break;
        }
    }
}

cell.IBlblLineNo.text=[NSString stringWithFormat:@"Line:%i",indexPath.row];
cell.IBlblLineText.text=[arrTemp objectAtIndex:indexPath.row];
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];

CGSize expectedlineLabelSize = [cell.IBlblLineText.text sizeWithFont:cell.IBlblLineText.font constrainedToSize:CGSizeMake(280, 1000) lineBreakMode:NSLineBreakByTruncatingTail];
cell.IBlblLineText.numberOfLines=expectedlineLabelSize.height/17;

CGRect frmlbl=cell.IBlblLineText.frame;
frmlbl.size.height=expectedlineLabelSize.height;
cell.IBlblLineText.frame=frmlbl;

return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

AutoLayoutTableViewCell *cell = (AutoLayoutTableViewCell *)[IBtblAutoLayoutExample cellForRowAtIndexPath:indexPath];

cell.IBlblLineNo.text=[NSString stringWithFormat:@"Line:%i",indexPath.row];
cell.IBlblLineText.text=[arrTemp objectAtIndex:indexPath.row];

[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];

CGSize expectedlineLabelSize = [cell.lineLabel.text sizeWithFont:cell.lineLabel.font constrainedToSize:CGSizeMake(280, 1000) lineBreakMode:NSLineBreakByWordWrapping];

 cell.IBlblLineText.numberOfLines=expectedlineLabelSize.height/17;
CGRect frmlbl=cell.IBlblLineText.frame;
frmlbl.size.height=expectedlineLabelSize.height;
cell.IBlblLineText.frame=frmlbl;

CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
height += 1.0f;

return height;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
     AutoLayoutTableViewCell *cell = (AutoLayoutTableViewCell *)[IBtblAutoLayoutExample cellForRowAtIndexPath:indexPath];

 CGSize expectedlineLabelSize = [cell.IBlblLineText.text sizeWithFont:cell.IBlblLineText.font constrainedToSize:CGSizeMake(280, 1000) lineBreakMode:NSLineBreakByTruncatingTail];

 return expectedlineLabelSize.height;

}

У меня есть 2 вопроса:

Моя проблема, я получаю ошибкуEXE_BAD_EXCESS рядом с линией

AutoLayoutTableViewCell *cell = (AutoLayoutTableViewCell *)[IBtblAutoLayoutExample cellForRowAtIndexPath:indexPath]; 

вheightForRowAtIndexPath а такжеestimatedHeightForRowAtIndexPath.

Почему я должен написать текст метки в обоихcellForRowAtIndexPath а такжеheightForRowAtIndexPath?

Кроме того, я что-то упустил для достижения динамической высоты для ячейки?

Ответы на вопрос(1)

Ваш ответ на вопрос