How to create DropDown in xcode?
I am a very new developer for IOS, i need help, How to create dropdown box in xcode, any one provide me example to create country list in drop down?
Solution 1:
Here I found two demos for dropDown list, One is creating custom expandable UITableViewCell
like :-
to
source code :- DEMO
AND Another is custom Drop Down list like:-
by clicking of test then open drop down list as bellow like image
source code with Tab Bar:-DEMO
updated source code without Tab Bar :-
http://www.sendspace.com/file/83qws5
Solution 2:
I beleive you shouldn't use dropdown boxes in iOS, as it's a desktop OS UI control element. You should think up something else using existing components (like PickerView), that's the words for UI consistency.
And if you need this anyway, you may create a table view, place it beneath your label and a triangular button(which causes it to appear and disappear) and populate it with values.
Solution 3:
Since there are no native DropDown
elements in iOS, you could make use of a TextField
with custom background and a UITableView
to accomplish that. Here is how to go about it.
Pseudocode
- Create a
TextField
and set it's delegate to parent controller - Implement
UITextFieldDelegate
and implement thetextFieldShouldBeginEditing
method - Create a new
UIViewController
and implementUITableView
in it programmatically. - Create a custom protocol and create it's object (delegate) it.
- In
textFieldShouldBeginEditing
method, load this controller and present it modally passing the required table's data source and set delegate as parent. - in the new
tableViewController
, implementUITableViewDelegate
and implement the didSelectRowAtIndex path method. - Upon row selection, call the delegate with passing appropriate data.
- dismiss the modally presented controller.
Solution 4:
just for whom searching for small simple swift combo box here in 2016 year, i've tried a few of old and new (but obj-c) libs, and at last selected this:
https://github.com/sw0906/SWCombox
here is screenshot: