Using Swift4, iOS11.1, Xcode9.1,
I would like to achieve dynamic height-change of one tableView-cell. The problem is as follows: Each cell in my tableView contains a UIView (called MyCellView). Upon user-touching of a cell this MyCellView of the touched cell shall change its height!
I successfully implemented a UIGestureRecognizer that brings me the action. In the action-method I change the height of the touched cell (so far so good). The view actually changes its height.
But unfortunately, if the MyCellView's new height is bigger than the original cell-height than the MyCellView is clipped off !
How can I dynamically achieve a cell-height change of a single cell in a tableView ?
Here is my gesture-recognizer action code:
@objc func toWebviewTouch(_ sender : UITapGestureRecognizer) {
self.MyCellView.frame = CGRect(x: self.MyCellView.frame.origin.x,
y: self.MyCellView.frame.origin.y,
width: self.MyCellView.frame.width,
height: self.myNewHeight)
self.contentView.bringSubview(toFront: self.MyCellView)
self.contentView.setNeedsLayout()
self.setNeedsUpdateConstraints()
self.updateConstraintsIfNeeded()
}
I also followed the ideas of this link. But this only seems to change the tableView cell's height upon tableView-filling (and not once the tableView is established and the user touches cells).
Any help appreciated !