Vikings
Vikings

Reputation: 2527

iPhone Picker Help

I have a picker setup, and it is displaying the output of the picker to a label. However, I have to click a button for that too happen. How can I display the picker contents a user is selecting without having to hit a button.

Edit: I forgot to mention that my picker has two columns. If anyone has code examples that would be great.

Upvotes: 0

Views: 158

Answers (3)

Wolfador
Wolfador

Reputation: 319

You should be able to use the didSelectRow method. Once a row is selected that method will run.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html

This does not work so well with multiple components as once one component is selected it grabs the values for all of them.

Upvotes: 1

benwong
benwong

Reputation: 2226

To perform an action when the user selects a row in UIPickerView, you need to set the pikcerview's delegate and implement – pickerView:didSelectRow:inComponent:.

Upvotes: 0

JohnQApple
JohnQApple

Reputation: 41

Implement a UIPickerViewDelegate, and then you can use the appropriate callback method to modify your label (probably pickerView:didSelectRow:inComponent:). See this link.

Upvotes: 0

Related Questions