0

How can I make my UIViews to expandable/collapsible UIView embedded in ScrollView. enter image description here

enter image description here

This is my mainview and when the user taps on the button the view automatically resize(+200 height) itself and the views below it will automatically adjust so as the scroll view.

Edit: I think I can't use TableView because I'm making a automation form like this enter image description here

So my idea here is that whenever the switch is turn on, the label will be added in the email form and the switch acts as the (Expande/collapse) trigger of the child of the parent.

RonPelayo
  • 376
  • 5
  • 22
  • 2
    use tableView for this kind of UI behaviour. and next time please post some code on what you tried. – santhu Feb 17 '14 at 07:58
  • I can't use tableview because each view has its own elements like view1 has 2 UITextfiel and 1 switch while view2 has 1 UITextfield and 2 slider. – RonPelayo Feb 17 '14 at 22:47

2 Answers2

1

The View can be a revised version of Accordion View, You can get some ideas here

After all a table view is a collection view on scrollView, so if you have time you can make the whole functionality yourself in four simple Functions for

  1. drawOuterList : to draw the outer list as fully customisable views on a scrollView
  2. handleButtonForExpandingOuterList : Decide to expand or close the view.
  3. drawInnerList : to draw the inner list as fully customisable views on a scrollView
  4. handleButtonForExpandingInnerList : Decide to expand or close the view.

there are many other links too Go through these links like

  1. expandable View
  2. expandable tableView
Maniac One
  • 589
  • 4
  • 23
0

If time is significant for you I advise to use on of ready solutions from cocoa controls

cocoa control search

In case you want to implement this on your own yo can create table view with custom cells. Make cells of two types :
1) fold cell
2) expanded cell

And reload the table on didSelectRowAtIndexPath. Table view is already subclass of ui scroll view, so it will do all resize work for you

Roma
  • 1,107
  • 9
  • 19
  • I can't use tableview because each view has its own elements like view1 has 2 UITextfiel and 1 switch while view2 has 1 UITextfield and 2 slider. – RonPelayo Feb 17 '14 at 22:48