anoop
anoop

Reputation: 59

Creating a drop-down list in iPhone app

When I click the button with an arrow symbol, the list of items available should be displayed as a list. Could anyone help me with the code for developing this for an iPhone application?

Upvotes: 3

Views: 33382

Answers (4)

Malaxeur
Malaxeur

Reputation: 6043

Does it have to be a drop down list? The standard here is to use a UIPickerView (especially on the iPhone) like Safari does whenever you have a drop down list. Not only is it standard, but it's way simpler than what I'm about to propose.

Well, if your answer is 'yes, it has to be a drop down list on the same screen', you're stuck implementing it yourself. This could be rather painful, but off the top of my head, your best bet would be to to create a UITableView (which will act as your PickerView) and create a custom UITableViewCell that only has a label (or maybe label + icon, or however you wish). Whenever the user presses your arrow (sic)sumbol, you display the view by either animating it in underneath the arrow or by just making it appear. Remember, you will have to have some controller acting as the UITableViewDelegate and UITableViewDataSource.

If your answer is 'no, that sounds complicated' go with the picker.

Upvotes: 1

Chris Conover
Chris Conover

Reputation: 9039

To answer the actual question though, there is a discussion here:

How to create a dropdown tableview like Vine App

Upvotes: 0

taskinoor
taskinoor

Reputation: 46037

iPhone does not have a built-in dropdown / selection list. You need to implement this yourself. This link contains a similar implementation using table view.

EDIT: UIPickerView is another option as pointed in other answers. You should also consider this.

Upvotes: 1

Matthew Frederick
Matthew Frederick

Reputation: 22305

UIPickerView is the correct control, the one that iOS users expect, and the control specified by the Apple iOS Human Interface Guidelines.

Even on a web page in Safari, wherever there would normally be a drop down a picker is displayed instead. Go with the picker if you at all can.

Upvotes: 13

Related Questions