(液)
謝謝大家誰回答,我想通了我自己,雖然,我只是要發佈的情況下,有人在這裏解決其他需要它幫助的未來。
(%的總和percentused其中設定爲100作爲默認PercentRemaining通過percentotal-percentUsed確定其中在開始爲0。)
滑塊的初始化包括在本:
slider1.minimumValue = 0.0;
slider1.maximumValue = [appDelegate getSlider1Percent] + [appDelegate getPercentRemaining];
然後滑塊動作: - (IBAction爲)slider1Action:(UISlider *)發件人 {
NSUInteger value = sender.value;
self.slider1Counter.text = [NSString stringWithFormat:@"%d%%",value];
NSUInteger currentSlider1Percent = [appDelegate getSlider1Percent];
appDelegate.slider1Percent = value;
if(appDelegate.getSlider1Percent < currentSlider1Percent)
{
nowFree = currentSlider1Percent - value;
appDelegate.percentUsed = [appDelegate getPercentUsed] - nowFree;
appDelegate.percentRemaining = [appDelegate getPercentTotal] - [appDelegate getPercentUsed];
slider2.maximumValue = [appDelegate getSlider2Percent] + appDelegate.getPercentRemaining;
slider3.maximumValue = [appDelegate getSlider3Percent] + appDelegate.getPercentRemaining;
slider4.maximumValue = [appDelegate getSlider4Percent] + appDelegate.getPercentRemaining;
slider5.maximumValue = [appDelegate getSlider5Percent] + appDelegate.getPercentRemaining;
}
else
{
nowFree = value - currentSlider1Percent;
appDelegate.percentUsed = [appDelegate getPercentUsed] + nowFree;
appDelegate.percentRemaining = [appDelegate getPercentTotal] - [appDelegate getPercentUsed];
slider2.maximumValue -= nowFree;
slider3.maximumValue -= nowFree;
slider4.maximumValue -= nowFree;
slider5.maximumValue -= nowFree;
}
}
我希望能幫助一些人!
乾杯!