I use UITableView and I want change the height of different cells. But I don't want use reload data for this because my table view contains UITextView which I edit in now and UIKeyBoard is up.
Asked
Active
Viewed 1.7k times
17
2 Answers
17
You're looking for the reloadRowsAtIndexPaths: method on the UITableView. It will trigger the recalculation of height (and subsequent redraw) of specific cells. It can even animate the adjustment so that you can do the update in real-time as the user is scrolling, such that the table view does not "jerk around" or "stutter step" while the heights are recalculated. I just implemented it successfully to do what you described.

Community
- 1
- 1

Zane Claes
- 14,732
- 15
- 74
- 131
-
4Reloading the table may dismiss the keyboard if the row's height changes. – aksommerville Aug 17 '12 at 20:01
-
4The question specifically ask for a way to do that without dismissing the keyboard. reloadRowsAtIndexPaths dismisses the keyboard – JP Hribovsek Sep 05 '13 at 20:48
-
21`[self.tableView beginUpdates];[self.tableView endUpdates];` will not dismiss the keyboard. This works if you have a text view embedded in the cell. – eulr Mar 20 '14 at 05:30
3
You can call beginUpdates && endUpdates
, These will causes table cell heights to be recaluclated,
without reloading the entire cell
UIView.setAnimationsEnabled(false)
self.tableView.beginUpdates()
self.tableView.endUpdates()
// Re-enable animations
UIView.setAnimationsEnabled(true)

Carlos Chaguendo
- 2,895
- 19
- 24