Reputation: 65
How can I create a multi select picker? I've a list of items and I want them to show in a picker with the option to multi select them, with checkmarks.
I've seen this while using an app, can somebody explain how this can be achieved?
I somehow solved the it partially, but can't figure out how to put checkmarks on the left, this is what I did
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = (UILabel*) view;
if (label == nil)
{
label = [[UILabel alloc] init];
}
[label setText:@"Whatever"];
[label setTextColor:[UIColor whiteColor]];
[label setBackgroundColor:[UIColor blackColor]];
CGSize rowSize = [pickerView rowSizeForComponent:component];
CGRect labelRect = CGRectMake (0, 0, rowSize.width, rowSize.height);
[label setFrame:labelRect];
return label;
}
Upvotes: 0
Views: 1461
Reputation: 1904
You should implement UIPickerViewDelegate methods, in your case i believe pickerView:viewForRow:forComponent:reusingView:
is the one you need.
Upvotes: 0