Table View Cell Row Height doesnt work

前端 未结 8 1042
故里飘歌
故里飘歌 2021-02-05 03:39

I have tried to hard code the row height in the table view cell. After running the program it looks like only one line. I suspect it is because of the height of the row

8条回答
  •  走了就别回头了
    2021-02-05 03:51

    Set row height as well as estimated row height as Automatic in viewDidLoad() as

    table.rowHeight = UITableViewAutomaticDimension
    table.estimatedRowHeight = UITableViewAutomaticDimension
    

    In heightForRowAt: set height as UITableViewAutomaticDimension as

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }
    

    Note: Set number of lines of label long restaurant name as 0.

提交回复
热议问题