滚动时为什么单元格会跳?

时间:2018-08-19 19:00:37

标签: ios swift uitableview uitableviewautomaticdimension

我与UITableView一起使用带有numberOfLines = 0,标签的单元格,这意味着该单元格可以显示1行或20行。

我的问题是滚动不流畅。

** estimatedRowHeight没有帮助。

class SingleTopicControllerV2: UITableViewDelegate, UITableViewDataSource {

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = self.table.dequeueReusableCell(withIdentifier: self.cellId, for: indexPath) as! ReplyCellV2
    cell.delegate = self
    cell.setupCellWithReply(reply: reply, user: self.user, index: indexPath.row)
    return cell
}

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

}

class ReplyCellV2: UITableViewCell {
func setupCellWithReply(reply: Reply, user: CurrensUserRealm, index: Int) {
    self.index = index

    if RealmService.shared.realm {
        self.reply = reply
        self.usernameBtn.setTitle(reply.owner.firstName, for: .normal)
        self.contentLabel.text = reply.content
        self.dateLabel.text = reply.time
    }
    self.setupRole(roleStr: reply.owner.role)
}
}

0 个答案:

没有答案