开发者

Customized UIPickerView and components

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开发者_Go百科 checkmarks. I've seen this while using an app, can somebody explain how this can be achieved .

Multiselect UIPicker

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;
}


This solved the problem. It's a ready to use ....

https://github.com/alexleutgoeb/ALPickerView


You should implement UIPickerViewDelegate methods, in your case i believe pickerView:viewForRow:forComponent:reusingView: is the one you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜