Take the 2-minute tour ×


@property (nonatomic, strong) IBOutlet UISlider *slider;


@synthesize slider;

- (void)viewDidLoad
    [super viewDidLoad];

    currentValue = 50;
    self.slider.value = currentValue;



The UISlider in my interface is connected to the slider property.


The slider sits all the way to the right at value 100 when it is supposed to be in the middle. An action I set up confirms the value of currentValue is 50. If currentValue is 50 and slider.value is set to 50, why doesn't the position reflect this?

P.S. I tried [slider setNeedsDisplay] and it did not affect this behavior.

Update: thanks for the quick answers! What a silly thing to do. I print out currentValue as an int elsewhere so I am now setting slider.value with this code:

self.slider.value = (float) currentValue/100;
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
currentValue = 50;

The slider's range is not 0...100 but 0...1. You have to write either

currentValue = 0.5;

or change the range of the slider:

self.slider.maximumValue = 100;
share|improve this answer
add comment

Default range for UISlider is 0.0 to 1.0 (i.e. as a Float). Setting a value above max will cause the slider to show all the way to the right. Check your minimumValue and maximumValue properties.

share|improve this answer
add comment

Your Answer


