UISlider disappearing when calling setValue with 0

Posted by Kai on Stack Overflow See other posts from Stack Overflow or by Kai
Published on 2010-04-14T04:04:40Z Indexed on 2010/04/14 4:13 UTC
Read the original article Hit count: 294

Filed under:
|

I have several UISliders in my application which all work fine until I call the following code:

...
frame = CGRectMake(43, 210, 201, 23);
mySlider = [[UISlider alloc] initWithFrame:frame];
[mySlider addTarget:self action:@selector(sliderUpdate:) forControlEvents:UIControlEventValueChanged];
mySlider.minimumValue = 0.0;
mySlider.maximumValue = 1.0;
mySlider.continuous = YES;
tempNum = [myArray objectAtIndex:2];
mySlider.value = [tempNum floatValue]; // only breaks if value is 0
[self.view addSubview:mySlider];
...

For some reason the slider doesn't show up unless mySlider.value is set to greater than 0. The only workaround I've found so far is to set it to an extremely small value (such as 0.000000001), which makes the slider appear as expected. Does anyone have any idea why this might be happening and how it can be fixed?

© Stack Overflow or respective owner

Related posts about uislider

Related posts about setvalue