Using a UIPickerView with custom values

北城余情 提交于 2020-01-06 05:31:09

问题


Im using a navigation controller and a normal view. In the view I'd like a UIPickerView with custom values in it. It would have one column with about 15 values in it. And I want the ability to add an action to each value.

Is there any way I can do this using Xcode? I can't seem to find the corrent help.

Cheers.


回答1:


You need to look at the documentation for UIPickerViewDelegate.

In order to have an action for each value you will implement pickerView:didSelectRow:inComponent: and have a different action based on which row was selected.

For the contents of the rows you can implement pickerView:titleForRow:forComponent: if your contents are simple text.

If you want custom drawn contents you can provide a custom view for each row with the pickerView:viewForRow:forComponent:reusingView: method.

See the UICatalog example that is available in the iPhone Developer examples.



来源:https://stackoverflow.com/questions/453409/using-a-uipickerview-with-custom-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!