25

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.

user403015
  • 7,209
  • 19
  • 66
  • 100

11 Answers11

17

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.

Till
  • 27,559
  • 13
  • 88
  • 122
  • 2
    Totally agree here, just read the [HIG](http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/Introduction/Introduction.html), there isn no such thing because it's not really usable. – rckoenes Dec 06 '11 at 13:45
  • 4
    To be honest I find the iOS version of HTML ` – Darrrrrren Nov 05 '12 at 15:44
  • 1
    I completely disagree. If you have a button in the upper right, you press it, and some menu items appear - thats perfectely fine. Take a look at the App MyDataMgr's (I'm not affilated) preferences. There are ways to implement this in a way that fits perfectely, pretty and usable. – brainray Jan 18 '13 at 10:15
  • 35
    -1 for claiming 'not pretty, funky, usable enough'. This is just your own opinion. Tons of iOS apps have well-designed and usable drop down menus -- check out Vine. – eric Feb 26 '13 at 14:14
  • 8
    @rckoenes You guys are crazy, there are literally 100s of application that successfully use a "Pull down to reveal" paradigm. In fact, I would argue it's more recognized interaction than "swipe to delete" Have you ever used apple's notification center? – Ryan Romanchuk May 08 '13 at 08:30
  • @RyanRomanchuk yes this true and my answer is from 2011 before these where implemented. – rckoenes May 08 '13 at 15:05
  • 3
    I'm hoping Apple might consider adding support for something like HTML – Greg Brown May 23 '13 at 13:30
  • 1
    It was true at the time, that iOS lacked menus, but iOS has menus now. See UIMenu. – w0mbat Sep 21 '20 at 20:44
10

You may want to check the PullableView view discussed here

This is a sample image with a pullable view from the top, bottom, and left side. The one at the bottom is open already.

sample app

Community
  • 1
  • 1
Sergio
  • 469
  • 4
  • 14
10

iOS 14+

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/

Jenea Vranceanu
  • 4,530
  • 2
  • 18
  • 34
SimeonRumy
  • 363
  • 4
  • 9
8

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/

spring
  • 18,009
  • 15
  • 80
  • 160
  • 3
    +1 I agree that the apple picker (UIPickerView) is horrendous. In my opinion it's too big, awkward, and hard to style. It was maybe cute and flashy when iphone was still a novelty, but remember it's just a form control. Form controls aren't the stars of the show and shouldn't get that much screen space. IMHO – eric Feb 26 '13 at 14:23
6

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.

linuxfreakus
  • 297
  • 1
  • 4
  • 6
  • No, don't put the table-view in front of everything else, but make it smaller, so that you can see the backgroud, which is then greyed out. Benefit: if you want to go back, you don't need a back button - you can tab 'outside' of the small tableview to get back. Thats much better and more intuitive than a huge tableview taht hides everything, especially on the iPhone 5 (small fingers dont get the back button) and the iPad mini. – brainray Jan 18 '13 at 10:26
  • His intention was not to hide everything on the screen, but instead to simply layer it such that it doesnt get covered by other views. – golddove Jan 22 '14 at 00:59
3

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 :

enter image description here

j2emanue
  • 60,549
  • 65
  • 286
  • 456
  • 1
    I don't think an action sheet retains selection state, though (but I could be wrong about that). – Greg Brown May 23 '13 at 13:32
  • This is a good idea when just wanting to present the user with options to select from say a navaction item. Thank you bro. – thekevshow Aug 07 '14 at 05:51
2

You can put a tableview in a "popover". Popover is for iPad only.

enter image description here

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:

  • Add a scrollbar, or something else to prevent touches meant to scroll from just performing the "select and close" behavior. Scrollbars are inconsistent with standard touch screen interfaces.
  • To require some kind of press 'n hold behavior to perform the select and close behavior which is annoying, and also nonstandard. Users expect touches to select right away, not to have to hold it down.
  • OR put an OK button in the top right to dismiss the window, like Apple has done in that Popover shown above.

See all iOS controls here

bobobobo
  • 64,917
  • 62
  • 258
  • 363
  • I'm not sure why using a scroll view would be bad. In fact, UITableView extends UIScrollView, so you should get this for free if you use a table view. And a UITableView knows how to distinguish between a scroll gesture and a select gesture. – Greg Brown May 23 '13 at 13:37
  • Well, he's using a "pull down or drop down menu", presumably to save space. A UITableView knows how to distinguish between a scroll gesture and a select gesture, only as long as touching an element _in_ the UITableView doesn't _select and close_ the UITableView. A UITableView that _expands on touch_ may work too. – bobobobo May 23 '13 at 14:01
  • Yeah, I was envisioning something like your "table view that expands on touch" - i.e. something like a drop-down select in HTML. – Greg Brown May 23 '13 at 17:49
2

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...

David
  • 63
  • 5
2

Use tableview as suggestion from KartikArora and in combination of popover controller for iPad.

user523234
  • 14,323
  • 10
  • 62
  • 102
  • A UITableView in a popover control gets the job done, but it would be nice if Apple could provide a built-in control for this. It could use a popover on the iPad and push a new top-level view on iPhone/iPod Touch. – Greg Brown May 23 '13 at 13:34
1

Perhaps a popover is what you want..

WYPopoverController

https://github.com/nicolaschengdev/WYPopoverController

enter image description here

enter image description here

keithics
  • 8,576
  • 2
  • 48
  • 35
0

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..

Kartik
  • 779
  • 7
  • 22