2017-06-14 116 views
0

我實現了一個滑塊,其中值Max,Min和Gap(十進制值)是動態的。現在我需要得到滿足這三個值的輸出。從三個動態值中獲取Slider值Max,Min和Gap iOS Objective C

例如: -最小值爲3.0,最大值爲25,間隙爲0.3。所以,現在我的輸出應該是3.3,3.6,3.9,4.2等,其中最終值應該是25.

現在我無法得到這個數學正確的不同的動態值。任何幫助都會很棒。

+1

我思蓋普增值系列不能用準確的最大值來結束。 –

+0

差的有點是確定.. –

+0

@Zck請提供您是如何計算的系列 –

回答

0

在Objective C中

我沒有檢查目標C代碼,但是也許它會幫助你。試試吧。

float gapValue = 0.3; 
float minValue = 3.0; 
float maxValue = 25.0; 

float currentValue = gapValue; 
NSMutableArray *rangeValues = [NSMutableArray array]; 

/* while loop execution */ 
    while(true) 
    { 
     currentValue += gapValue ; 
     if currentValue <= maxValue { 
      [rangeValues addObject:currentValue]; 
     }else{ 
     break; 
     } 
    } 

NSLog(@"%@\n", rangeValues); 

在斯威夫特:

for i in stride(from: 3.0, through: 25.0, by: 0.3) { 
    print(i) 
} 
+0

ok..let我查 –

+0

感謝的代碼,但它只是給我( 「5.5」, 6「,6.5」,7「,7.5」,8「,8.5」,9「,9.5」,10「,10.5」,11「,11.5」,12「12.5」,13「,13.5」,14「 14.5「,15」,15.5「,16」,16.5「,17」,17.5「,18」,18.5「19,」19.5「,20」,20.5「,21」,「21.5」,22「,22.5」在第一次拖曳時比第一次拖曳時更容易地在第二次拖曳時將「23.5」,24「,24.5」,25「,25.5」,26「,26.5」,27「,」27.5「,28」,28.5「,29」,29.5「,30)在它返回空之後。 –

+0

很高興爲您提供幫助。如果您喜歡,可以點擊並接受它。 –