Xcode:使文本字段显示选择器视图或下拉菜单
有人可以提供一些示例代码,说明如何在 iOS 应用程序上创建以下功能:
选项 1: 我想通过 Interface Builder 创建一个文本字段,当有人单击该文本字段时,我希望它不显示默认键盘,而是显示一个选择器视图,其中列出了我喜欢的几个选项。用户完成选择某个值后,他们可以单击选择器视图旁边的“完成”按钮,选择器视图将消失,文本字段将填充他们在选择器视图上选择的内容。
选项 2 如果前面的方法需要太多代码才能完成,有人可以提供有关如何创建类似于网站上标准下拉菜单的基本下拉菜单的示例代码吗?
谢谢
Can someone please provide some example code on how I could create the following features on an iOS app:
Option 1:
I want to create a text field through Interface Builder, and when someone clicks on that text field, instead of bringing up the default keyboard, I want it to bring up a Picker View which lists several choices of my liking. Once the user is done picking a certain value, they can click on a "done" button by the picker view and the picker view will go away and the Text Field will be populated with what they chose on the Picker View.
Option 2
If the previous method will require too much code to accomplish, could someone provide example code on how to create a basic Drop Down menu similar to how a standard drop down menu on a website?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个新文件。我调用了我的 AEMPicker。 .h:
.m:
现在,在你想要展示你的 pickerView 的类中,在
#import AEMPicker;
添加到你的 .h:添加到你的 .m:
这应该会给你一个漂亮的可以使用的基本选择器弹出窗口。
Create a new file. I called mine AEMPicker. The .h:
the .m:
Now, in the class you want to present your pickerView, after
#import AEMPicker;
add to your .h:add to your .m:
That should give you a pretty basic picker popover to play with.