I have an old objective c project which has an UITableView
. All the UILabels
in each cells have been created by code. This is my cellForRowAtIndex
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *metadataListTableIdentifier = @"MetadataListTableViewCell";
MetadataTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:metadataListTableIdentifier];
NSMutableDictionary *dict = [theListData objectAtIndex:indexPath.row];
[MetrixListScreenManager setCellDataDictionary:dict];
if (cell == nil || cellReloadCount <= cellReloadLimit) {
cell = [MetrixListScreenManager generateCellForListScreen:self withReuseIdentifier:metadataListTableIdentifier andScreenId:self.screenId];
cellReloadCount++;
}
[SkinApplicationUITableViewController applySkinColorToRelevantControlsForCell:cell];
[MetrixListScreenManager populateCellDataForListScreenId:self.screenId usingCell:cell andDataRow:dict];
return cell;
}
According to this implementation, in generateCellForListScreen
method, all the labels are creating by giving fixed height and width. Then in populateCellDataForListScreenId
method all the texts are setting for previously created UILabels
. Now we want to make to adjust cell height according to the content height. So what I did was in generate cell method I got the text height and replace the predefined height with that. But my problem is when I scroll some UILabel
's height getting increased and rest of the UILabel
s are going beyond the cell bottom margin. What is the proper way to do this? Please help me.
Thanks