How do I create a multiline table cell in iOS?

前端 未结 4 1533
暖寄归人
暖寄归人 2021-02-03 13:40

How can I get the second cell to expand to fit the text rather than scaling the text? Is there a built in way of doing this in iOS or will I have to come up with some home-cook

4条回答
  •  一向
    一向 (楼主)
    2021-02-03 14:03

    Implement:

    - (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
    

    in your table delegate. For the different row and section in the passed indexPath, return a different height to fit your label.

    Ensure 'adjust to fit' for the label in IB is not ticked (property adjustsFontSizeToFitWidth if done using code).

提交回复
热议问题