
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 0.89 KB | hits: 11 | expires: Never
Any Way To Display 1/2 Instead of .5 In UIPickerView?
pickerArray = [[NSMutableArray alloc] initWithCapacity:700];
for ( float i = 0.0 ; i <= 1000.0 ; i = i + 2.5)
{
//[pickerArray addObject:[NSString stringWithFormat:@"%.1f", i]]
[pickerArray addObject:[NSNumber numberWithFloat:i];
}
float weight = [[pickerArray objectAtIndex:row] floatValue];
label.text = [NSString stringWithFormat:@"%.1f", weight];
NSMutableArray *array = [[NSMutableArray alloc] init];
for (int i=0;i<100;i++) {
float value = (float)i*2.5;
if (i % 2) {
[array addObject:[NSString stringWithFormat:@"%d %@",(int)value,@"1/2"]];
} else {
[array addObject:[NSString stringWithFormat:@"%d",(int)value]];
}
}
"0", "2 1/2", "5", "7 1/2", "10", "12 1/2", "15", "17 1/2", "20", "22 1/2", "25", "27 1/2", "30", "32 1/2", "35", "37 1/2", "40", and more
label.text = [array objectAtIndex:row];