Dinesh Kumar
Dinesh Kumar

Reputation: 1293

How to display the tableview in dropdown list on Button Click in iPhone?

I have tried this code. http://www.mediafire.com/download/bvoqrkn82sd6az9/tablesample.zip ..Here, I need like this.. whenever I click the show button, it should display the list of Tableview like dropdown as it is in this screenshot. When on load, table view should be hidden. When on click the button, tableview should display. Your help is highly appreciated. Thanks in advance.enter image description here

Upvotes: 1

Views: 1428

Answers (1)

Krishna Kumar
Krishna Kumar

Reputation: 1652

You can change height of tableView with animation. Set time according your suitability.

For Expansion:

[UIView animateWithDuration:1
                              delay:0.0
                            options: UIViewAnimationYourChoice
                         animations:^{
                            CGRect frame = self.tableView.frame;
                              frame.size.height = 300;
                             self.tableView.frame = frame;
                         }
                         completion:^(BOOL finished){
                             NSLog(@"Done!");
                         }];

For shrinking:

[UIView animateWithDuration:1
                              delay:0.0
                            options: UIViewAnimationYourChoice
                         animations:^{
                            CGRect frame = self.tableView.frame;
                              frame.size.height = 0;
                             self.tableView.frame = frame;
                         }
                         completion:^(BOOL finished){
                             NSLog(@"Done!");
                         }];

Upvotes: 5

Related Questions