iPhone 应用程序 - 弹出对话框 - 有点
我有一个 iPhone 应用程序,它本质上是一个列表。顶部有一个 UINavigationBar,然后有一个保存列表的 UITableView。我希望以某种方式提供一个选项,允许用户以不同的方式对列表进行排序。因此,在我看来,我想象 UINavigationBar 上有一个 NavigationItem,当触摸它时,会出现一个弹出对话框。您选择所需的“排序”,旁边会出现一个复选标记,然后对话框就会消失。
我不太确定该怎么做。我尝试创建一个 UIView,在其上添加一个 UIViewController (它在 UITableView 中保存了不同“排序”参数的列表(例如按字母顺序排序、按日期排序等)。 但是 UITableView 没有响应任何触摸,我不知道为什么。
有人知道如何使用Apple的精彩界面来提供这样的选项吗?我不能在UINavigationBar下面使用UISegmentedControl,因为有5个可能的选项,并且我无法将所有这些都放入一个 UISegmentedControl 中。
I have an iPhone application which is, in essence, a list. There is a UINavigationBar at the top, and then there is a UITableView which holds the list. I'd like to have an option in some way or another of allowing the user to sort the list in different ways. So, in my mind, I picture having a NavigationItem on the UINavigationBar that, when touched, a little pop up dialogue comes up. You select the "sort" you want, a check mark appears next to it, and the dialogue goes away.
I'm not really sure how to do this. I tried creating a UIView, adding a UIViewController onto it (which held this list of different "sort" parameters (ex. sort alphabetically, sort by date, etc) in a UITableView. But the UITableView isn't responding to any touches, and I'm not sure why.
Does anyone have an idea for using Apples wonderful interface for having an option like this? I can't use a UISegmentedControl below the UINavigationBar, because there are 5 possible options, and I can't fit all that in a single UISegmentedControl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不会得到复选标记,但如果您想要弹出窗口,我建议使用 UIAlertView。
You won't get a checkmark, but if you want a pop-up I suggest using a UIAlertView.
您是否研究过
UIActionSheet
? https://developer.apple.com/documentation/uikit/uiactionsheet看起来像它可能很适合这种方法。操作表会有点高,因为其中有 5-6 个按钮,但它应该可以完成工作,而且它们非常容易实现。
您通过显示另一个视图及其自己的 UITableView 来接近它的方式也可以工作,但对我来说这似乎不是最好的方法。当然,如果您打算采用这种方法,请向我们提供一些代码,以便我们可以尝试找出
UITableView
不响应触摸的原因。Have you looked into
UIActionSheet
at all? https://developer.apple.com/documentation/uikit/uiactionsheetIt seems like it might be a good fit for this approach. The action sheet will be a bit tall since you will have 5-6 buttons in it, but it should get the job done and they are really easy to implement.
The way you are approaching it with displaying another view with its own UITableView in it would work also, but it doesn't seem like the best approach to me. Granted, if you are set on going with that approach, provide us with some code so we can try to figure out why the
UITableView
isn't responding to touches.这听起来像是 UIPickerView 的工作。每当按下该按钮时,您都可以从视图底部向上滑动一个。我过去曾这样做过并且效果很好。
This sounds like a job for the UIPickerView. You could just slide one up from the bottom of the view whenever that button is pressed. I've done this in the past and it works well.