Skip to content

Instantly share code, notes, and snippets.

@indyfromoz
Created January 3, 2020 04:51
Show Gist options
  • Save indyfromoz/8c0ccfce3c44f606b5842adf42ce4a6d to your computer and use it in GitHub Desktop.
Save indyfromoz/8c0ccfce3c44f606b5842adf42ce4a6d to your computer and use it in GitHub Desktop.
Self-sizing UITableView cell - Force update of UI
// Via @layoutSubviews in /dev/world2019
func tableView( _ tableView : UITableView, didSelectRowAt indexPath: IndexPath ) {
let cell = tableView.cellForRowAt( indexPath) as! MyCell
// Make some changes that affect the layout. Doing this but nothing else will cause clipped content.
cell.label.fontSize = 100
// We have to force the table view to recalculate the cell size and update the UI
tableView.beginUpdates()
tableView.endUpdates()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment