Spencer Williams
Spencer Williams

Reputation: 922

How to hide UITableViewCell?

I have an app that includes a tableView. The tableView has several sections, and tapping a particular section title should show and hide the rows inside that section.

First of all, I couldn't use normal table sections, because section headers have no gesture delegate (unless they do?).

Secondly, I'm having trouble figuring out the best way to show and hide the table cells. I've already subclassed them to make the cellForRowAtIndexPath easier. If I [cell setHidden:YES] it will show the blank space where the cell should be, and my frame/bounds fu isn't high enough for me to play around with that effectively.

Thirdly, ideally the solution would allow me to use animation (a simple slide or squish).

Note: I'm using Xcode 4.3 and iOS SDK 5.0. My app uses a storyboard and ARC.

Upvotes: 0

Views: 2674

Answers (1)

lnafziger
lnafziger

Reputation: 25740

Changing the data source is the best way, but unfortunately this isn't always possible (ie static table views).

You can set them to hidden and have heightForRowAtIndexPath return 0 for the height of the cell.

Upvotes: 1

Related Questions