iOS 有下拉菜单吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8400801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:45:28  来源:igfitidea点击:

Any pull down or drop down menu for iOS?

iphoneiosipad

提问by user403015

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.

在我的 iOS 应用程序中,我需要使用下拉菜单。我不想使用操作表或选择器视图。

Is there any pull down or drop down menu for iOS?

iOS 有下拉菜单吗?

Thanks.

谢谢。

采纳答案by Till

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.

不,iOS SDK 中没有这样的东西,这是有充分理由的——这些元素在触摸屏上运行时不够漂亮、时髦和可用性不够好。

Consider using UIPickerViewor UISegmentedControlinstead.

考虑使用UIPickerViewUISegmentedControl代替。

But if you insist, check sites like Cocoa Controlsfor some derivates. Some of them are actually well done.

但是,如果您坚持,请查看Cocoa Controls 之类的站点以获取某些衍生物。其中一些实际上做得很好。

回答by Sergio

You may want to check the PullableView view discussed here

您可能需要检查此处讨论的 PullableView 视图

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

示例应用程序

回答by spring

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.

我不同意下拉列表在 iPad 上一定不好。苹果选择器是可怕的。但这完全取决于他们需要显示的数据类型和数量。

I just found this dropdown list and it looks/performs pretty well: http://blog.lemberg.co.uk/iphone-development/custom-dropdown-list/

我刚刚找到这个下拉列表,它看起来/表现得很好:http: //blog.lemberg.co.uk/iphone-development/custom-dropdown-list/

回答by linuxfreakus

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.

只要确保将 table view 放在其他所有东西的前面,这样它就不会被其他元素剪裁或隐藏。

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.

这确实取决于您选择的内容,但仍有一些地方我不确定如何避免使用选择器。

回答by j2emanue

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.

如果您考虑一下,操作表基本上是一个下拉列表。如果你不断向 UIActionSheet 添加按钮,它最终会变成一个表格。因此,只需让您的按钮调用 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 :

尝试向 UIActionSheet 添加 7 个或更多按钮,然后观察它变成一个列表。它的方便。这张照片可以用来演示我的意思:

enter image description here

在此处输入图片说明

回答by bobobobo

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

您可以将 tableview 放在“popover”中。Popover 仅适用于 iPad。

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 scrollfrom just performing the "select and close" behavior. Scrollbars are inconsistent with standard touch screen interfaces.
  • To require some kind of press 'n hold behaviorto perform the select and closebehavior 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.
  • 添加 scrollbar或其他内容以防止旨在滚动的触摸仅执行“选择并关闭”行为。滚动条与标准触摸屏界面不一致。
  • 为了需要某种按“N持有行为进行选择并关闭行为,这是烦人,还非标准。用户希望触摸可以立即选择,而不必按住它。
  • 或者在右上角放置一个 OK 按钮以关闭窗口,就像 Apple 在上面显示的 Popover 中所做的那样。

See all iOS controls here

在此处查看所有 iOS 控件

回答by user523234

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

根据 KartikArora 的建议使用 tableview,并结合 iPad 的 popover 控制器。

回答by Kartik

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

不,iOS SDK 中没有这样的东西,但您可以使用表格视图作为下拉列表 .. 为此,您必须设置表格视图的框架并将其显示为下拉列表。

回答by keithics

Perhaps a popover is what you want..

也许一个popover就是你想要的..

WYPopoverController

WYPopoverController

https://github.com/nicolaschengdev/WYPopoverController

https://github.com/nicolaschengdev/WYPopoverController

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明