iphone - UITableViewCell getting reused -
i have uitableview
called symptomtable ...and there remedytable when uiswitch
on in remedytable display uiimage
on symptomtableviewcell highlight uiswitch
on cell . when switch on in remedytable of first symptom displaying uiswitch
cell getting reused , image showing in other symptomtableview cell well. can help me out this?
-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (tableview==symptomstableview) { ppsymptomtablecell *cell; static nsstring *cellidentifier=@"cellidentifier"; cell=[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell==nil) { cell=[[ppsymptomtablecell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; cell.selectionstyle=uitableviewcellselectionstylenone; } int symptomidselected; symptomidselected = [[[mainsymptarray objectatindex:indexpath.row]objectforkey:@"symptid"]intvalue]; nslog(@"%d",[[activenotificationdictionary objectforkey:[nsnumber numberwithint:symptomidselected]]intvalue]); (int = 0; i<activenotificationdictionary.count; i++) { if([[activenotificationdictionary objectforkey:[nsnumber numberwithint:symptomidselected]]intvalue] == symptomidselected) { cell.selectedcellimagedisplay.hidden=no; } else { cell.selectedcellimagedisplay.hidden=yes; } } nslog(@"end of symptoms cell row"); if (searching==yes) { cell.symptomcelllabel.text=[[searchsymptomsarray objectatindex:indexpath.row] objectforkey:@"symptname"]; cell.backgroundcolor=[uicolor clearcolor]; homecoming cell; } else { cell.backgroundcolor=[uicolor clearcolor]; nsarray *sectionarray=[mainindexdictionary objectforkey:[allkeysarray objectatindex:indexpath.section]]; cell.symptomcelllabel.text=[[sectionarray objectatindex:indexpath.row] objectforkey:@"symptindexname"]; homecoming cell; } }
here activenotification dictionary nsmutabledictionary
contains value of remedyid particular symptomid. custom uitableviewcell
symptomtable
- (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { self.backgroundcolor = [uicolor clearcolor]; self.contentview.backgroundcolor = [uicolor clearcolor]; self.symptomcellimageview.contentmode=uiviewcontentmodescaletofill; selectedcellimagedisplay = [[uiimageview alloc]initwithimage:[uiimage imagenamed:@"selectedsymptomimage.png"]]; selectedcellimagedisplay.frame = cgrectmake(230.0, 8.0, 30.0, 30.0); selectedcellimagedisplay.hidden=yes; symptomcelllabel=[[uilabel alloc]initwithframe:cgrectmake(15.0,0.0 ,280.0,40.0)]; symptomcelllabel.font=[uifont fontwithname:@"rockwell" size:17]; symptomcelllabel.textcolor=[uicolor blackcolor]; symptomcelllabel.backgroundcolor=[uicolor clearcolor]; [self.contentview addsubview:symptomcelllabel]; [self.contentview addsubview:selectedcellimagedisplay]; // initialization code } homecoming self; }
the cell beingness reused because asked reused (dequeuereusablecellwithidentifier:
). because cell can reused, must explicitly set all features of every cell, including presence or absence of switch , state.
iphone ios objective-c uitableview
No comments:
Post a Comment