/ Published in: C#

Call this method to set the intervals for a UISlider in Monotouch. You can remove the textbox parameter if you don't have them linked to sliders.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Set interval for sliders, Update txtboxes, Update gross weight void setInterval(UISlider slider, UITextField txtBox, int interval){ // get the nearest interval value for(int i=(int)slider.MinValue; i<=(int)slider.MaxValue; i=i+interval){ if(slider.Value > i && slider.Value < i + interval){ if(slider.Value - i < i + interval - slider.Value){ slider.Value = i; }else{ slider.Value = i + interval; } break; } } txtBox.Text = slider.Value.ToString(); UpdateGrossWeight (); }
Comments
