I have a UITableView with a Custom label in every cell. The label displays an amount of money. The UIPickerView has a load of different currency symbols in it's array. I want to be able to display the selected currency symbol from the pickerView in the custom label in the tableview on every cell. Any ideas on how I could achieve this?
This is my picker view code:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
list = [[NSMutableArray alloc] init];
[list addObject:@"£"];
[list addObject:@"$"];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return[list count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return[list objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
currency = [NSString stringWithFormat:@"%@",[list objectAtIndex:row]];
NSLog(@"Currency: %@", currency);
}
This is how I create the label in the cellForRow...
Code:
Item *i = (Item *) [appDelegate.items objectAtIndex:indexPath.row];
secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(145.0, 37.0, 96.0, 20.0)] autorelease];
secondLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];
secondLabel.textAlignment = UITextAlignmentLeft;
secondLabel.adjustsFontSizeToFitWidth = YES;
secondLabel.tag = 3;
secondLabel.textColor = [UIColor darkGrayColor];
secondLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:secondLabel];
secondLabel = (UILabel *)[cell viewWithTag:3];
secondLabel.text = [NSString stringWithFormat:@"(%@ each )", i.notes];
Thanks for your help.