objective c - How to Dynamically change the Maximum Value of UISliders, iOS? -
i have 5 uisliders. total sum of 5 should 100. now, start in default 20. therefore, shouldn't go above 20 in beginning, since sum of of them 100. now, lets move uislider1 , put down 10. mean sum between 5 90, therefore have 10 "freed up". uislider2 should able increase 30. or uislider2 25 , uislider3 25 again.
my question is, how do this? how dynamically (programatically) change maximum value of uislider depending on values of others?
thanks!
edit: @ answer.
how this?
// create slider [slider1 addtarget:self action:@selector(slidervaluechanged:) forcontrolevents:uicontroleventvaluechanged]; [slider2 addtarget:self action:@selector(slidervaluechanged:) forcontrolevents:uicontroleventvaluechanged]; // ... etc. // somewhere else -(void)slidervaluechanged:(uislider *)sender{ float total = slider1.value + ... + slider5.value; float delta = 100 - total; slider1.maximumvalue = slider1.maximumvalue + delta; slider2.maximumvalue = slider2.maximumvalue + delta; // ... etc. }
Comments
Post a Comment