UITableView dynamic cell heights only correct after some scrolling

后端 未结 24 1242
误落风尘
误落风尘 2020-11-29 16:41

I have a UITableView with a custom UITableViewCell defined in a storyboard using auto layout. The cell has several multiline UILabels.

24条回答
  •  死守一世寂寞
    2020-11-29 17:21

    In my case, I was updating in other cycle. So tableViewCell height was updated after labelText was set. I deleted async block.

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier:Identifier, for: indexPath) 
         // Check your cycle if update cycle is same or not
         // DispatchQueue.main.async {
            cell.label.text = nil
         // }
    }
    

提交回复
热议问题