ios - UILabel of a TableViewCell changes position on reloadData and onClick -
i have tableview inside viewcontroller , every time try reloaddata or click cell. specific label moves higher , stays there.
before reload or click!:
after reloaddata or click cell:
any ideas going wrong?
i call read function data in database , store them in nsmutablearray sitetableobjectsarray.
dispatch_async(backgroundqueue, ^(void){ [self read:^(bool finished) { if(finished){ dispatch_async(dispatch_get_main_queue(), ^{ sitetableobjectsfinalarray = [sitetableobjectsarray copy]; nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"work.title" ascending:yes]; nsarray *sortdescriptors = [nsarray arraywithobject: sortdescriptor]; sitetableobjectsfinalarray = [sitetableobjectsfinalarray sortedarrayusingdescriptors:sortdescriptors]; [self.tableview reloaddata]; }); } }]; });
i copy array nsarray, ( use 2 arrays reason) , use array populate table follows:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ workcell *cell = (workcell *) [tableview dequeuereusablecellwithidentifier:@"workcell"]; sitetableobject *obj = [sitetableobjectsfinalarray objectatindex:indexpath.row]; authors *currauth = obj.author; works *currentwork = obj.work; cell.authorlabel.text = currauth.authorname; cell.worklabel.text = currentwork.title; nsstring* cleanedstring = [obj.text stringbytrimmingcharactersinset: [nscharacterset symbolcharacterset]]; cell.textlabel.text = cleanedstring; cell.caategorylabel.text = [categoriesdictionary objectforkey:[nsstring stringwithformat:@"%@",currentwork.categoryid]]; cell.datelabel.text = [nsstring stringwithformat:@"%@", currentwork.date]; cell.morelabel.text = [nsstring stringwithformat:@"%i more",obj.more]; return cell;
}
-(void)tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath{ cell.backgroundcolor = [uicolor clearcolor];
}
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{ workcell *cell = (workcell *) [tableview cellforrowatindexpath:indexpath]; currentindexrow =indexpath.row; sitetableobject *clickedobject = [sitetableobjectsfinalarray objectatindex:indexpath.row]; works *clickedwork = clickedobject.work; selectedworkid = [clickedwork.workid intvalue]; if ([cell.morelabel.text isequaltostring:@"0 more"]) { [self performseguewithidentifier:@"p" sender:self]; }else{ [self performseguewithidentifier:@"more" sender:self]; }
}
and every time call reloaddata comes same result either have changed sitetableobjectsfinalarray or not!
after digging in code found notification in workcell.h: "auto property synthesis not synthesize property 'textlabel' because 'readwrite' synthesized 'readonly' via property."
i found out solution notification noticed!
i had add:
@synthesize textlabel in workcell.m file
Comments
Post a Comment