UIPickerView选择和隐藏
如何使 UIPickerView
表现得像带有 webview 的那样,其中有一个下拉选择框,而不是像通常的网站那样下拉,iphone
将其变成包含所有选择的 UIPickerView
。当您选择一个时,您的选择旁边会出现一个勾号,并更改下拉框的值。如何将“完成”按钮放在 UIPickerView
顶部以关闭 UIPickerView
?
我已经知道 [pickerview setHidden:YES]
是用于隐藏 pickerview 的方法。我只是不知道如何在 UIPickerView
中包含“完成”按钮。
问候, 克里斯
How do you make a UIPickerView
act like the one with a webview wherein there is a drop down selection box and instead of dropping down like usual websites do, the iphone
makes it into a UIPickerView
with all the selections in. When you select one, a check becomes visible beside your selection and changes the value of the drop box. And how do you put the "Done" button on top of the UIPickerView
to dismiss the UIPickerView
?
I already know that [pickerview setHidden:YES]
is the method to use to hide the pickerview. I just don't know how to include the "Done" button in the UIPickerView
.
Regards,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这段代码将滑出一个选择器视图作为键盘,并在其顶部附加一个完成按钮。基本上,您想使用输入字段设置 inputAccessoryView。
您应该在输入字段的触地事件上调用此方法。
最后,您的“完成”按钮调用“pickerDoneClicked”方法,您应该在其中添加
[yourTextField resignFirstResponder];
这将隐藏选择器视图。This piece of code will slide out a picker view as keyboard and attached a done button on top of it. Basically, you want to set a inputAccessoryView with your input field.
You should call this method on a touch down event for your input field.
Finally, your Done button calls the "pickerDoneClicked" method, where you should add
[yourTextField resignFirstResponder];
which will hide the picker view.“完成”按钮放置在 UIToolBar 中。
使用 UIToolBar 的以下方法添加“完成”按钮。
The "Done" button is placed in UIToolBar.
Use the below method of UIToolBar for adding the "Done" buttons.