In my iOS app, I need to use pull down or drop down menu. I do not want to use action sheet or picker view.
Is there any pull down or drop down menu for iOS?
Thanks.
In my iOS app, I need to use pull down or drop down menu. I do not want to use action sheet or picker view.
Is there any pull down or drop down menu for iOS?
Thanks.
No, there is no such thing within the iOS SDK and that is for a good reason - those elements are just not pretty, funky and usable well enough when acting on a touch display.
Consider using UIPickerView
or UISegmentedControl
instead.
But if you insist, check sites like Cocoa Controls for some derivates. Some of them are actually well done.
Ages later, things have changed - mostly due to the vastly increased screen estate. We now have UIMenu.
Pull-down menus have been introduced in iOS 14. After iOS 15 they were renamed as pull-down buttons.
Here is a link to the guidelines: https://developer.apple.com/design/human-interface-guidelines/components/menus-and-actions/pull-down-buttons/
To create a simple pull down menu from a navigation bar, add a bar bottom item either in code or the storyboard, then call this in viewDidLoad to create a simple menu:
func setupMenu() {
let add = UIAction(title: "Add", image: UIImage(systemName: "plus")) { (action) in
print("Add")
}
let edit = UIAction(title: "Edit", image: UIImage(systemName: "pencil")) { (action) in
print("Edit")
}
let delete = UIAction(title: "Delete", image: UIImage(systemName: "minus"), attributes: .destructive) { (action) in
print("Delete")
}
let menu = UIMenu(title: "Menu", children: [add, edit, delete])
barItem.menu = menu
}
You can find more details in this guide: https://www.appcoda.com/colorpicker-datepicker/
I don't agree that a dropdown list is necessarily bad on the iPad. The Apple picker is horrendous. But it all really depends on they type and amount of data that needs to be displayed.
I just found this dropdown list and it looks/performs pretty well: http://blog.lemberg.co.uk/iphone-development/custom-dropdown-list/
I don't really see what the big deal is with using a "drop down" as long as it is big enough to use. I made one that uses a table view, it is much faster, easier to use, and less visually abusive than the default picker. Every time I see one of those default pickers it makes me cringe, they look horrible and they take too long to use. It really doesn't take a lot of code, I'm not sure why more people don't use them.
Basically what you do is make a button that looks like a drop down, and then have it activate and slide in a table view when the button is activated. Implement the regular delegate methods as normal to handle item selection, then slide it back out again.
Just make sure to put the table view in front of everything else so it is not clipped or hidden by other elements.
It does depend on what you are picking though, there are still places where I'm not sure how I would avoid the use of a picker.
The action sheet is basically a drop down list if you think about it. And if you keep adding buttons to a UIActionSheet it ends up turning into a table. So just have your button call a UIActionSheet.
Try adding 7 or more buttons to the UIActionSheet and watch it turn into a list. Its convenient. This photo can be useful to demo what i mean :
You can put a tableview in a "popover". Popover is for iPad only.
As I commented above, this construction is probably the best you can do on a touch screen. Think about a dropdown that requires scrolling. The default browser behavior is click once to open the menu, 2nd click does both select and close the menu.
-
But you can't have that exactly on touch devices, not without some modifications. Because touch screens don't have hover, to scroll through the list you have to either:
I know I might be 9 years late to answer this, but iOS now have a pull–down menu: https://developer.apple.com/design/human-interface-guidelines/ios/controls/pull-down-menus/
Maybe you just were ahead of your time...
Use tableview as suggestion from KartikArora and in combination of popover controller for iPad.
Perhaps a popover is what you want..
WYPopoverController
https://github.com/nicolaschengdev/WYPopoverController
No, there is no such thing within the iOS SDK but you can use table view as a dropdown liat .. for that you have to settle frame of tableview and display it like dropdown list..