views:

170

answers:

2

This slider is possessed: Slider

Whenever I enter "editing mode" for the tableview or leave "editing mode" a duplicate thumb image will appear where the thumb is. It is now behaving consistently in this way. If I switch back and forth from editing mode I'll get lots of thumb images like the screenshot shows.

This is the code that I use to create the slider (in the cellForRowAtIndexPath method):

CGRect frame = CGRectMake(20, 42.0, 280.0, 22);
self.slider = [[UISlider alloc] initWithFrame:frame];
[self.slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
self.slider.continuous = YES;
self.slider.minimumValue = 0.0;
self.slider.maximumValue = 5.0;
self.slider.value = 0.0;
[[interestCell contentView] addSubview:self.slider];

Appreciate any thoughts you might have!

[I just edited/updated this to reflect the questions/suggestions I received but it's still having problems].

+1  A: 

Try adding it to the cell's contentView and not the cell itself.

coneybeare
I added it to the contentView and the only difference is that now the possessed behavior is quite consistent. Every time I click the edit button to put the table in editing mode, I get a duplicate thumb image, and I also get one when I take it out of editing mode. Any other thoughts?
Gorgando
A: 

Finally figured it out!

I had to move my code to the viewDidLoad method except for setting the slider to the contentView, which happens in the cellForRowAtIndexPath method still. What a strange problem that was. Thanks to those who helped and commented!

Gorgando