Help with labels and sliders

Discussion in 'iPhone/iPad Programming' started by iphonedevelop18, Mar 1, 2009.

  1. macrumors member

    Joined:
    Feb 26, 2009
    #1
    I am having trouble with outputting the value of a slider in a text format. So how do i get it so when i move the slider the label outputs the sliders value?
     
  2. macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #2
    Code:
    - (IBAction)sliderChanged:(id)sender
    {
    	UISlider *slider = (UISlider *)sender;
    	int progressAsInt = (int)(slider.value + 0.5f);
    	NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
    	sliderLabel.text = newText;
    	[newText release];
    }
    
    This gets the value of of the slider and sets the value to a label text. You would fire this IBAction from the Value Changed Outlet of the Slider Control
     
  3. thread starter macrumors member

    Joined:
    Feb 26, 2009
    #3
    thanks so much
     

Share This Page