iphone - UITableView scroll problem -
i have created tableview in application 5 sections in it.
sections 1 - 4 contain 1 row each minute , section 5 contains 5 rows.
everything works fine until scroll tableview off screen. in first section , row (cell) have accessoryview set uilabel text in it.
every other cell has disclosure button accessorytype.
when scroll tableview text have in first cell somehow appears in the last cell!?
i have set data adding nsstrings array's , adding them dictionaries nsmutablearray.
and here cell set up:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; } // uiswitch *auiswitch = [[[uiswitch alloc]initwithframe:cgrectzero]autorelease]; // configure cell. nsdictionary *dictionary = [listofsettings objectatindex:indexpath.section]; nsarray *array = [dictionary objectforkey:@"settings"]; nsstring *cellvalue = [array objectatindex:indexpath.row]; cell.textlabel.text = cellvalue; if([cellvalue isequaltostring:@"status"]){ uilabel *viewlabel = [[uilabel alloc]initwithframe:cgrectmake(0, 0, 100, 20)]; [viewlabel settext:@"connected"]; cell.accessoryview = viewlabel; [viewlabel release]; } else{ cell.accessorytype = uitableviewcellaccessorydetaildisclosurebutton; } return cell; }
i know cells deleted/removed when go off screen presume has it? recommended practice dealing cells go off screen , reappear?
just @ quick glance... in else statement, not need set cell.accessorytype, set cell.accessoryview=nil;
the accesoryview still there cell recycled.
Comments
Post a Comment