开发者

UISlider not holding values in UITableView

开发者 https://www.devze.com 2023-02-06 07:28 出处:网络
For whatever reason.. when I move past it (go down), the slider gets weird and it graphica开发者_Python百科lly changes and doesnt retain a value.

UISlider not holding values in UITableView

For whatever reason.. when I move past it (go down), the slider gets weird and it graphica开发者_Python百科lly changes and doesnt retain a value.

UISlider not holding values in UITableView

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


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];
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消