0

I have a UIPickerView where I load an NSMutableArray *column in it. In the *column array, I have a few UIImageViews as array's objects. At runtime, I would like to change the SELECTED item's image ONLY while maintaining the other's item's image. How can I do this? I can get the row of selected item with:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

}

But kinda stuck here. Any ideas?

GeneCode
  • 7,545
  • 8
  • 50
  • 85

1 Answers1

1

You need to change your source array and reload that component ( column ) such as :

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
       [column replaceObjectAtIndex:row withObject:[UIImage imageName@"YourImage.png"]];
       [pickerView reloadComponent:component];

}
Ugur Kumru
  • 986
  • 6
  • 9
  • Hi Ugur Kumru, thanks for the tip! It helps me a lot! It is not really the precise answer, but I'll accept it as it helped me to figure it out. Here's what I used instead since my objects are UIImageViews and not UIImage: [[self.column objectAtIndex:row] setImage:[UIImage imageNamed:@"Selector2On.png"]]; [pickerView reloadComponent:component]; – GeneCode Mar 09 '12 at 12:25
  • Sorry I thought you had the images in your dataSource. Glad it helped. – Ugur Kumru Mar 09 '12 at 12:26