Note that there are some explanatory texts on larger screens.

plurals
  1. POShow entire number value after chosen on UIPickerView?
    primarykey
    data
    text
    <p>I have a little coding problem at the moment. I have a picker with 7 different options, currently for testing purposes I have a label that will display the chosen value of the picker. </p> <p>The problem that I am having is that my label is only displaying whole numbers, not displaying the entire decimal number, can someone please help me so that I can obtain the full value of the chosen item in the picker?</p> <p>Here is my code :</p> <pre><code>// returns the number of 'columns' to display. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } // returns the # of rows in each component.. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [tempList count]; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [tempList objectAtIndex:row]; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { CGFloat chosenValue; switch (row) { case 0: chosenValue = 0.0000373; break; case 1: chosenValue = 0.0000273; break; case 2: chosenValue = 0.0000233; break; case 3: chosenValue = 0.0000204; break; case 4: chosenValue = 0.0000179; break; case 5: chosenValue = 0.0000169; break; case 6: chosenValue = 0.0000142; break; default: chosenValue = 0; break; } NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init]; formatter.numberStyle = NSNumberFormatterDecimalStyle; self.testLabel.text = [formatter stringFromNumber:@(chosenValue)]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload