如何实现类似的菜单视图? [iOS]
有没有办法使用 sdk 轻松实现此菜单,还是必须手动制作(将覆盖视图和其他视图与按钮结合起来)?
提前致谢!
Is there a way to achieve this menu easily with the sdk or do I have to make it manually (combining an overlay view and other view with the buttons)?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是标准 UIKit 框架中的 UIActionSheet 类
That's UIActionSheet class from standard UIKit framework
来自 Apple 的
UIActionSheet
文档 由我进行了一些扩展,以触发呼叫操作。ViewController 全局范围内的 Delcare:
UIActionSheet * actionSheet;
和UIView * yourView;
Int the viewDidLoad:
要通过某个带有 IBAction 声明的按钮来触发菜单,您将需要:
根据用户选择采取适当的操作声明以下方法并检查
[actionSheet buttonTitleAtIndex:buttonIndex]
等于什么:[注意:调用的触发在 iOS 模拟器上不起作用]
Easy example from Apple's documentation of
UIActionSheet
extended a bit by me to fire call action.Delcare in the global scope of the ViewController:
UIActionSheet * actionSheet;
andUIView * yourView;
Int the viewDidLoad:
To fire the menu by some declared button with IBAction you will need:
To take appropriate action depending on user choice declare following method and check what
[actionSheet buttonTitleAtIndex:buttonIndex]
was equal to:[NOTE: Firing of call does not work on iOS Simulator]