Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Any Way To Display 1/2 Instead of .5 In UIPickerView?
  2. pickerArray = [[NSMutableArray alloc] initWithCapacity:700];
  3. for ( float i = 0.0 ; i <= 1000.0 ; i = i + 2.5)
  4. {
  5.     //[pickerArray addObject:[NSString stringWithFormat:@"%.1f", i]]
  6.     [pickerArray addObject:[NSNumber numberWithFloat:i];
  7. }
  8.  
  9. float weight = [[pickerArray objectAtIndex:row] floatValue];
  10. label.text = [NSString stringWithFormat:@"%.1f", weight];
  11.        
  12. NSMutableArray *array = [[NSMutableArray alloc] init];
  13. for (int i=0;i<100;i++) {
  14.     float value = (float)i*2.5;
  15.     if (i % 2) {
  16.         [array addObject:[NSString stringWithFormat:@"%d %@",(int)value,@"1/2"]];
  17.     } else {
  18.         [array addObject:[NSString stringWithFormat:@"%d",(int)value]];
  19.     }
  20. }
  21.        
  22. "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
  23.        
  24. label.text = [array objectAtIndex:row];