2011-11-28 70 views
-1

我需要配置一個十進制值,以便它顯示從1 - 100浮點數,如12.34。現在,它只顯示0到1之間的浮點數,所以我得到0.12。需要移動浮點值的小數點

如何進行更改,使小數點右移兩位?

這是在Xcode 4.2適用於iOS的方法的代碼:

- (IBAction)sliderMoved:(UISlider *)slider 
{ 
    NSLog(@"The value of the slider is now: %.2f", slider.value); 
} 
+2

乘以100? – beryllium

回答

1

簡單地乘以從界面設計師,選擇您的UISlider和改變數值範圍(最小和最大):

enter image description here

+0

謝謝你,真讓我不知所措。 – pdenlinger

2

你不能乘以100的價值?

3
NSLog(@"The value of the slider is now: %.2f", slider.value*100);