Here I attached the gif file. Refer this
在我的tableview中,我有一个带自动布局的自定义xib单元格。当我运行项目时,得到的问题就像gif文件一样。
我的tableview函数
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "requestsCell", for: indexPath) as? RequestsTableViewCell
cell?.backgroundColor = .clear
let passengerName = cell?.viewWithTag(1) as! UILabel
let bookingCreator = cell?.viewWithTag(2) as! UILabel
let department = cell?.viewWithTag(3) as! UILabel
let product = cell?.viewWithTag(4) as! UILabel
passengerName.text = "Muhammed yasheed"
bookingCreator.text = "Muhammed Yasheed"
department.text = "Programming"
product.text = "Flight"
cell?.approvedView.isHidden = false
cell?.cancelView.isHidden = true
return cell!
}
答案 0 :(得分:0)
最后我找到了答案。只需在cellForRowAt索引路径
中添加单元格?.layoutIfNeeded()cell?.layoutIfNeeded()