3

I am doing an application form in my app and I want to make something creative, so I thought of having the form components in sections (like the following images), and do a collapse and expand affect on them.

collapsed expanded

Is there is any class or something which could help me implementing this or I have to do it manually?

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
  • I added the images for you :) – Carl Veazey Feb 28 '13 at 10:27
  • What is the base `UIView` subclass you are using? If it's `UITableView` then tag your question with it and change "Objective-C" to "table view" in your title. – trojanfoe Feb 28 '13 at 10:30
  • 1
    1) http://www.cocoanetics.com/2011/03/expandingcollapsing-tableview-sections/ 2) http://stackoverflow.com/questions/1938921/expand-collapse-section-in-uitableview – βhargavḯ Feb 28 '13 at 10:30

1 Answers1

3

I used to take advantage of a UITableView and the methods

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths 
  withRowAnimation:(UITableViewRowAnimation)animation

and

- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths 
  withRowAnimation:(UITableViewRowAnimation)animation

to simulate and expand/collapse behaviour.

Refer to the documentation for more details.

I've used then selectable section headers (either via UIButton or gesture recognizers) to let the user expand/collapse.

There are also a lot of tutorials out there that are quite explanatory, using different techniques:

Finally you can take a look to this control that should provide the functionality that you are searching for:

UIExpandableTableView

Nicola Miotto
  • 3,647
  • 2
  • 29
  • 43