2011-05-12 100 views
0

如何创建多选择选择器。我有一个项目列表,我希望他们能够在选择器中显示多选的选项,并带有选中标记。 我在使用应用程序时看到了这一点,有人可以解释如何实现这一点。定制的UIPickerView和组件

Multiselect UIPicker

我莫名其妙地解决了这部分,但无法弄清楚如何把对号左边,这是我做的

- (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; 
} 
+0

没有人可以帮我这个????来吧家伙...指导我在这里 – donito 2011-05-16 13:37:34

回答

0

你应该实现UIPickerViewDelegate方法,在你的案例我相信pickerView:viewForRow:forComponent:reusingView:是你需要的。

+0

感谢您的答复,你能指点我的示例代码或任何我可以看看。作为新手,我很难理解你的意思。请帮忙。 – donito 2011-05-14 00:10:35

+0

我以某种方式解决了它的一部分,但无法弄清楚如何把左边的复选标记。我更新了我的文章,请查看代码并帮助我。 – donito 2011-05-14 23:19:04