iOS8: Possible to use “tableview.rowHeight = UITableViewAutomaticDimension” for static cells?

前端 未结 8 992
慢半拍i
慢半拍i 2020-12-14 17:00

I have a UITableView that has five static cells. I need the cell height of one cell to adjust automatically to its contents, which is one UILabel.

Is there any way I

8条回答
  •  再見小時候
    2020-12-14 17:32

    I assume that I would need to tell the cell to redraw using something like

    [self.tableView beginUpdates];
    [self.tableView reloadRowsAtIndexPaths:@[indexPathOfYourCell] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];
    

    When it comes to dynamically changing the height of the tableviewcells.

    -(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return Yourvalue; //return whatever u want ur cell to have size.
      }
    

提交回复
热议问题