如何在 iPhone 中创建自定义 Picker 视图控制器?
我想创建一个自定义选择器视图控制器。当用户选择选择器列表中的特定数据时,将显示所选类别的复选标记图像。如何将自定义图像设置为所选类别。我创建了一个标签并显示内容在自定义标签中。但我只想在选择类别时显示图像。 我在google上搜索了很多文档和示例程序。但我没有得到任何明确的想法。所以请帮帮我。
查看我的屏幕截图
谢谢。
I want to create a custom picker view controller. When user selects the particular data in the picker list, then will displayed the check mark image for selected category. How do i set the custom image as selected the category. I have created a label and displayed the contents are in the custom label. But i want to displayed the images only, when selects the category.
I have searched for many docs and sample programs in the google. But i didn't get any clear idea. So please help me out.
see my screen shot
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为使用
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
正如我在聊天中建议的那样room 不会帮助您实现此 UI。我认为你最好使用单元格之间没有分隔符的 UITableView 并将图像放置在表格上方,这样它看起来就像一个选择器。
此处使用常规
UIPicker
的问题是您希望移动所选行。在选择器中,选定的行是位于中心的行...
I think that using
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
as I have advised you in the chat room won't help you achieve this UI.I think that you are better use a
UITableView
with no separators between cells and place an image above the table so that it will look like a picker.The problem using a regular
UIPicker
here is that you want the selected row to move.In the picker the selected row is the one that is located in the center...
您应该使用以下默认方法在选择器控件中添加自定义视图:
谢谢
You should add custom view in picker control using below default method :
Thanks