dsaw
dsaw

Reputation: 577

ios UITableView - functioning like a dropdown list

Requirement : implementing a drowdown functionality in an UIView

The known way is using a UIWebView.

My Q is can this be done via a TableView?

Is there any way which lets me select a section(just like selecting a row), so that I can implement a hide/show cells of a section when that particular section is selected?

Upvotes: 2

Views: 3740

Answers (1)

sergio
sergio

Reputation: 69047

Don't know if I am understanding you correctly, but it seems to me that what you want can be done like this:

  1. have a UITableView with several sections;

  2. each section has got just one row;

  3. when a specific row for a section is selected (didSelectRowAtIndex), you change the data source associated to that section by adding more elements and reloadData on the table.

  4. when a specific row for a section is selected you also modify the data source corresponding to any other section so that it only contains one row.

EDIT:

From your last comment, it seems to me that what you are trying to do is a generic dropdown menu: you click somewhere and it displays; now, in your specific case you are thinking of clicking on a table, but it could in principle be anywhere else. I am saying this (if I am not wrong), because if it is so, then you can find ready-made implementations, like WEPopover, and you could save some effort.

Going back to your asking, in the case you are mentioning, you can animate the height of the table view frame (or bounds), so that its content is displayed little by little, as the view height increases; have a look at this Tutorial about Core Animations.

Upvotes: 4

Related Questions