views:

156

answers:

1

I'm using a pickerView with multiple components related to several fields in a Database (CoreData). Is it possible to change the fontcolor for a specific component according the presence of data in the DB ? For example the field in the DB is null the component font color should be RED otherwise black.

Any help will be appreciated !

Dario

================== Thanks Kenny,

I have to apply to a single UIPicker only. So I', returning the view parametere (without modificatiosn). The result is all the pickers show empty rows.

Thanks for help !

Here you will find the code fragment:

  - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {

if (pickerView == tipoPk){
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100,30)];
label.textColor =      [UIColor redColor];
switch (component) {
case PK_Tipo:
label.text =  [tipoArray objectAtIndex:row]];
break;
case PK_Settore:
label.text =  [settoreArray objectAtIndex:row]];
break;
default:
break;
}
return label;
}
else {
return view;    // <====   return view for non related pickerviews , but no rows shown
}  


}
A: 

Yes, but you have to use -pickerView:viewForRow:forComponent:reusingView: and supply a custom UILabel.

KennyTM