I have a customized UISlider which has its track image disappear sometimes. It happens at random and when its parent view controller is pushed to visible (I never see it actually disappear).
Here is my code for setting up the UISlider:
timeSlider = [[UISlider alloc] initWithFrame:CGRectMake(55, 8, 210, 23)];
timeSlider.backgroundColor = [UIColor clearColor];
UIImage *blutrackImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetrack" ofType:@"png"]];
UIImage *whitetrackImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"whitetrack" ofType:@"png"]];
//UIEdgeInsetsMake(top,left,bottom,right)
UIImage *stetchLeftTrack = [blutrackImg stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [whitetrackImg stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
[timeSlider setThumbImage: [UIImage imageNamed:@"whiteslide2.png"] forState:UIControlStateNormal];
[timeSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[timeSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
timeSlider.continuous = NO;
[timeSlider addTarget:self action:@selector(trackTime:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:timeSlider];
I am building on iOS 5.0. Has anyone ever ran into such a thing?
SOLUTION FOUND: I believe this problem was caused by the following mistake:
I had a timer which was setting the value of the slider using the slider.value property instead of the [slider setValue: animated:] method. I was also not sanity checking the value being set.
Addressing those to issues has solved the problem.