ios - Resizing UITableViewCell contentview width. -
i want make uitableviewcell width 280 , start @ (20,0)
meaning there should 20 points insets on x axis cell.
however, when change table cell's contentview frame - entire cell behind black square of size want , new cell looks this
this code this: in viewdidload of tableviewcontroller
[tableview registernib:[uinib nibwithnibname:[self layoutname] bundle:[nsbundle mainbundle]] forcellreuseidentifier:[self cellidentifier]];
initialize of cell
-(void)initialize{ // [self setbackgroundcolor:[uicolor clearcolor]]; // [self settintcolor:[uicolor clearcolor]]; self.backgroundview = [[wbchildcellbackground alloc]initwithframe:cgrectinset([self frame], 20, 0)]; [self.backgroundview sethidden:yes]; self.contentview.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin | uiviewautoresizingflexibleheight | uiviewautoresizingflexibletopmargin | uiviewautoresizingflexiblebottommargin; self.autoresizingmask =uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin | uiviewautoresizingflexibleheight | uiviewautoresizingflexibletopmargin | uiviewautoresizingflexiblebottommargin; self.contentview.contentmode = uiviewcontentmoderedraw; self.autoresizessubviews = yes; self.contentview.autoresizessubviews = yes; self.contentmode = uiviewcontentmoderedraw; self.originalframe = self.frame; }
and call code:
-(void)layoutsubviews{ [super layoutsubviews]; cgrect frame = self.bounds; frame.origin.x = frame.origin.x + self.cellinset; frame.size.width = frame.size.width - 2*self.cellinset; if(self.cellinset == 0){ frame = self.originalframe; } self.contentview.bounds = frame; [self.contentview layoutsubviews]; } -(void)setcellinset:(cgfloat)cellinset{ _cellinset = cellinset; [self layoutsubviews]; }
why doesn't cell change way want?
Comments
Post a Comment