View Full Version : UIPickerView enquiries

Jul 20, 2010, 02:25 AM
very green in iphone programming so yeah need to clarify few doubts.

1. how do I add new columns to the picker view?
2. how do I make it spin literally like a (jackpot) slot machine upon a click of a button?
3. how do I add in images?

fyi: suppose to come up with a slot machine application.

Jul 20, 2010, 03:58 AM
1) Your datasource supplies the number of components (http://developer.apple.com/iphone/library/documentation/iPhone/Reference/UIPickerViewDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIPickerViewDataSource/numberOfComponentsInPickerView:)

2) To the best of my knowledge you can't: the control is for user picking. You will need to create your own custom UIView or UIControl subclass for that

3) Your delegate can supply any view for a specific component and row (http://developer.apple.com/iphone/library/documentation/uikit/reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html#//apple_ref/occ/intfm/UIPickerViewDelegate/pickerView:viewForRow:forComponent:reusingView:). This could be a UIImageView.

Jul 20, 2010, 08:48 AM
When you set the value of the picker it can animate to its new value. If you continue to change the value I guess you could make it spin a lot. Not sure if you can really make it look like a slot machine though.