How to increase cell height based on the label text(Dynamic) in cell.In the below code lblAnswer is getting dynammic data, based on this the cell height should increase. Tried below code, but doesn't work for me. TIA
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
EmpViewCell *cell = (EmpViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[EmpViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.lblAnswer.lineBreakMode = NSLineBreakByWordWrapping;
cell.lblAnswer.numberOfLines = 0;
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"EmpViewCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (EmpViewCell *) currentObject;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
}
}
NSMutableDictionary* emmpdict = [_emparr objectAtIndex:indexPath.row];
cell.lblEmpName.text = [NSString stringWithFormat:@"%@",[emmpdict objectForKey:@"EmployeeName"]];
cell.lblQuestion.text=[NSString stringWithFormat:@"%@",[emmpdict objectForKey:@"Question"]];
cell.lblAnswer.text=[NSString stringWithFormat:@"%@",[emmpdict objectForKey:@"Answer"]];
return cell;
}