I have a UIPickerView display with the inputView of a textField. I have split the pickerView into two columns. One is whole numbers 50-500. The other is 0.25,0.50,0.75. I want them to be able to select the whole number, and then the decimal part of the number with the other column. I can't figure out how to get to display the "full" number. When i move the second column, it just registers it as moving the column one and changes the whole number. I want the user to be able to select a whole number, the decimal part of the number, hit done and the textField display a number with format "100.25" or whatever number they select. I have the done button coded...and the whole number displays with just format i.e "100".
Thanks!
UPDATE!!! CODE!!!!
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent: (NSInteger)component{
if ([pickerView isEqual:weightPickerView]) {
weightField.text = [NSString stringWithFormat:@"%d.%d",[weightPickerArray objectAtIndex:row], [weightPickerArray2 objectAtIndex:row]];
-(void)populateWeightPickerArray{
weightPickerArray = [[NSMutableArray alloc] init];
for (int weight = 50; weight <=500; weight++) {
NSString *weightString = [NSString stringWithFormat:@"%d%",weight];
[weightPickerArray addObject:weightString];
}
}
-(void)populateWeightPickerArray2{
weightPickerArray2 = [[NSMutableArray alloc] init];
[weightPickerArray2 addObject:@"0.25"];
[weightPickerArray2 addObject:@"0.50"];
[weightPickerArray2 addObject:@"0.75"];
}
So I want the user to select their weight-- for example 100 with column one and 0.25 in column two. Then I want the text field to display 100.25...
UPDATE 2! changed code, and now I receive an error..
[Session started at 2012-08-03 10:39:39 -0500.] 2012-08-03 10:39:45.656 CalorieAppFinal[1088:207] -[NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x4b336c0 2012-08-03 10:39:45.661 CalorieAppFinal[1088:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x4b336c0' * Call stack at first throw
here is how I initialize my weightPicker
-(IBAction)weightFieldDidBeginEditing{
weightPickerView = [[UIPickerView alloc] init];
weightField.inputView = weightPickerView;
weightPickerView.showsSelectionIndicator = YES;
weightPickerView.delegate = self;
weightPickerView.dataSource = self;
[weightPickerView release];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
if ([pickerView isEqual:weightPickerView]) {
int valOne = [[weightPickerArray objectAtIndex:row] intValue];
CGFloat valTwo = [[weightPickerArray2 objectAtIndex:row] floatValue];
weightField.text = [NSString stringWithFormat:@"%d.%.2f",valOne, valTwo];
}
-(void)populateWeightPickerArray{
weightPickerArray = [[NSMutableArray alloc] init];
for (int weight = 50; weight <=500; weight++) {
[weightPickerArray addObject:[NSNumber numberWithInt:weight]];
}
}
-(void)populateWeightPickerArray2{
weightPickerArray2 = [[NSMutableArray alloc] init];
[weightPickerArray2 addObject:[NSNumber numberWithFloat:0.25f]];
[weightPickerArray2 addObject:[NSNumber numberWithFloat:0.50f]];
[weightPickerArray2 addObject:[NSNumber numberWithFloat:0.75f]];
}