我想在PickerView中显示一些颜色名称,它们是UIColr类的常量
pickerContent = [[NSArray alloc] initWithObjects:[UIColor redColor],[UIColor orangeColor],[UIColor purpleColor],[UIColor yellowColor], nil ];
我为PickerView标签实现的函数是
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [(UIColor *)[self.pickerContent objectAtIndex:row] description];
}
我知道描述不会给我我想要的输出。
所以请帮助您提出宝贵的建议。
答案 0 :(得分:2)
如果您只想在Picker视图中显示颜色名称,那么请选择另一个NSArray
NSArray *colourArray=[[NSArray alloc] initWithObjects:@"redColor",@"orangeColor",@"purpleColor",@" yellowColor", nil ];
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{ return [colourArray objectAtIndex:row];
}