Reputation: 2799
I know that this question has been asked 100's of times but I can't find a good fit for me.
I'm using a UITableViewController
with static cells. I want to be able to expand and collapse a certain cell programmatically, and I thought that animating it's height would be a good idea. But how can I do this?
I dont want to use insertRowsAtIndexPaths
because my UITableView
is static and I don't want to use heightForRowAtIndexPath
because meny of my cells have different heights and I don't want to enter all of them and change them there every time I make a change in the storyboard.
I was hoping for a simple "Get cell and use UIView animateWithDuration
" But can't find a solution for that.
What options do I have?
Upvotes: 2
Views: 624
Reputation: 119242
With static table views, a UITableViewController has its own implementation of the datasource and delegate methods, where it reads the appropriate height from the storyboard file.
Override heightForRowAtIndexPath:
, and call the super implementation. This gets you the height as defined in the storyboard.
Then, for the index path whose height you want to modify, simply return your modified value.
To animate this change, call beginUpdates
and endUpdates
on the table view.
Upvotes: 7