views:

76

answers:

0

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?