Search code examples
iphonedoublepicker

Independent Double picker


I have double picker one picker for suit (heart, diamond etc) of a card and the other the value of the card (king, ten, two etc). What I want to know how do I eliminate a value from the card picker once it was already selected so it cant be chosen again?


Solution

  • Keep your UIPickerView's data stored in an NSMutableArray. Then, when the user makes his choices, remove those objects from the data source array, and call

    [self.myPickerView reloadAllComponents];
    

    This will only work, of course, if you're not hardcoding the value for numberOfRowsInComponent:, but doing something like

    - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
        return [dataArray count];
    }