创建从底部向上滚动的菜单的最佳方法?
我对 iPhone 编程相当陌生,我正在制作一个相当基本的应用程序。无论如何,我只想知道如何创建一个从底部(从选项卡栏顶部开始)向上滚动的菜单,显示一些选项。我附上了一张图片,可以更好地描述我的意思。我假设我应该创建某种子视图,然后向其中添加一些动画,但我想获得您关于最佳开始方式的建议。 谢谢
I'm fairly new to iPhone programming, and I'm making a fairly basic app. Anyway, I just want to know how to go about creating a menu that scrolls up from the bottom (beginning at the top of the tab bar) that displays a few options. I've attached a picture that better helps portray what I mean. I'm assuming I should create some sort of subview and then add some animation to it, but I'd like to get your advice on the best way to start.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的解决方案是使用未修改的 UIActionSheet。
如果这不是您想要的,那么使用模态视图控制器始终是一个选择。
但是,如果您想要的东西不会覆盖整个屏幕,并且可以具有自定义外观,则基本思想是这样的:
代码如下所示:
The simplest solution would be to use a UIActionSheet, unmodified.
If that's not what you're looking for, using a modal view controller is always an option.
If, however, you want something that won't cover the entire screen, and can have a custom look, the basic idea is this:
The code would look something like this:
我自己没有这样做,但看到了一个很酷的源代码,它是在 UIScrollView 的帮助下执行的(默认情况下位于屏幕“下方”),包含 UITableView 和一个按钮(显示在屏幕底部)屏幕)。按下此按钮后,ScrollView 收到移动命令(在其 IBAction 中)。
篇幅较短,尝试看看 UIScrollView(在其中玩一下 UITableView)。
I didn't do it myself, but saw a cool source-code, where it was performed with the helped of UIScrollView (by default positioned "below" the screen), containing UITableView and a button (wich was shown at the bottom of the screen). ScrollView was getting a command to move after the press of this button (in IBAction of it).
Being shorter, try to look at UIScrollView (play with UITableView in it).
我做了类似的事情,通过子类化 UIActionSheet 并将我自己的控件添加为子视图,从屏幕底部弹出一些对象。我想在您的情况下可以使用类似的方法。
创建实现
UITableViewDelegate
和UITableViewDataSource
协议的 UIActionSheet 子类。在该类的- (id)init
方法中,添加一个UITableView
作为子视图,并以self
作为委托和数据源。然后从主视图中,使用
showInView:
调用自定义 UIActionSheet。使用委托回调主视图,让它知道用户何时选择一个选项,然后使用
[myCustomMenu DismissWithClickedButtonIndex:0animated:YES]
隐藏菜单。I've done something similar, popping up some object from the bottom of the screen by subclassing UIActionSheet and adding my own controls as subviews. I imagine a similar method could be used in your situation.
Create a subclass of UIActionSheet implementing the
UITableViewDelegate
andUITableViewDataSource
protocols. In the- (id)init
method of that class, add aUITableView
as a subview withself
as the delegate and data source.Then from the main view, call your custom UIActionSheet with
showInView:
.Use delegates to call back to the main view to let it know when the user selects an option, then use
[myCustomMenu dismissWithClickedButtonIndex:0 animated:YES]
to hide the menu.