logixologist
logixologist

Reputation: 3834

UISlider not holding values in UITableView

what I start off with

For whatever reason.. when I move past it (go down), the slider gets weird and it graphically changes and doesnt retain a value.

What I end up with

Notice you can see a shadow of where it was. Any help is greatly appreciated.

Upvotes: 0

Views: 549

Answers (1)

logixologist
logixologist

Reputation: 3834

I just found the answer....

All your custom "initWithFrame" code like this:

UISlider *theSlider =  [[[UISlider alloc] initWithFrame:CGRectMake(55,20,220,45)] autorelease];
theSlider.maximumValue=10;
theSlider.minimumValue=0;       
    [cell addSubview:theSlider];

Has to be inside this block, or else every time it will try to redraw:

 if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
 }

I had it like this:

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 

UISlider *theSlider =  [[[UISlider alloc] initWithFrame:CGRectMake(55,20,220,45)] autorelease];
theSlider.maximumValue=10;
theSlider.minimumValue=0;       
    [cell addSubview:theSlider];
 }

Upvotes: 1

Related Questions