Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement drop down box in iphone?

I have a view and I hv a button on that.I need to have a drop down box on clicking that button. How to implement drop down box?? Drop down box shuold have a table view.When I click rows in table view(after drop down box will open) I want to get text which will be there on the clicked row cell on a view where I had button. How to do that?

like image 376
Vijay Avatar asked Oct 08 '10 10:10

Vijay


People also ask

What is the drop down called on Iphone?

Control Center gives you instant access to the things you do the most. You can use Control Center to quickly take a picture, turn on Wi-Fi, control your Apple TV, and more.

How do you add a drop down to a button?

Use any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.


1 Answers

Here's a workaround that works for me.

-(IBAction)showDropDownList:(id)sender
{

tableView = [[UITableView alloc] initWithFrame:CGRectMake(7, 135, 200, 0) style:UITableViewStyleGrouped];
        tableView.delegate = self;
        tableView.dataSource = self;

    if (tableState == TableViewStateClosed) {  //enum for identifying tableview state

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        CGRect viewRect = self.tableView.frame;
        viewRect.size.height += 150;

        [self.tableView setFrame:CGRectMake(7, 135, 200, viewRect.size.height)];

        [UIView commitAnimations];
        [self.view addSubview:tableView];
        tableState = TableViewStateOpen;
    }
    else if (tableState == TableViewStateOpen) {

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];

        [self.inboxTableView setFrame:CGRectMake(7, 135, 200, 0)];

        [UIView commitAnimations];

        tableState = TableViewStateClosed;
    }
}
like image 109
SamG Avatar answered Sep 28 '22 06:09

SamG