Return to Snippet

Revision: 64786
at September 20, 2013 04:37 by negzero7


Initial Code
// 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 ();
		}

Initial URL

                                

Initial Description
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.

Initial Title
Set Intervals for sliders

Initial Tags
ios, c#

Initial Language
C#