Requirement;
I have a static UITableView and I'm trying to open a pickerview when one of the cells is clicked. I change the size with heightForRowAt so when the cell is clicked I need to reload it so that the size changes. If I use reloadData() it works perfectly (I want to use reloadRows so I can add animation)
Issue:
when I try reloadRows(at..., with: .automatic) the rows simply disappear. If I reloadRows in viewWillAppear nothing changes, the row does not disappear.
Code:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath)
if colorCelllExpandedIndex != nil{
let prev = colorCelllExpandedIndex
colorCelllExpandedIndex = nil
tableView.reloadRows(at: [prev!], with: .automatic)
//tableView.reloadData()
} else {
colorCelllExpandedIndex = indexPath
colorCell.frame.size.height = CGFloat(colorCellExpandedHeight)
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
}
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath == colorCelllExpandedIndex {
return CGFloat(colorCellExpandedHeight)
} else {
if indexPath.row == 1 {
return CGFloat(colorCellRegularHeight)
}
return UITableViewAutomaticDimension
}
}
Screen Images:

