views:

11

answers:

0

I have a UITableView A, in which there is a cell (in a standalone section) that, once selected, another UITableView B will be brought up where user can input/edit text content. After done with UITableView B, the text content will be used to update the cell's content in UITableView A.

The cell section in UITableView A was coded to allow variable height like the following code does. But somehow, the height of the cell was not changed after I changed the content in UITableView B. I debugged into the code and found out that the tableView:heightForRowAtIndexPath was called once once when the UITableView A is loaded. How can I get it called again to reflect the new content getting from UITableView B? Do I have to specifically refresh the cell? Is there a way to do so? Note that user can select the cell and update the content of the cell as many times as they want.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath  *)indexPath {
    CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - CELL_CONTENT_MARGIN * 2 - CELL_ACCESSORY_WIDTH, 9999.0f);
    CGSize size = [self.myText sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
    CGFloat height = MAX(size.height + CELL_CONTENT_MARGIN * 2, SECTION_HEIGHT);

    return height;
}