i have custom uitableviewcell text view.
the textview's height increases according text.
i can't figure out how increase cell height fit text view.
here code:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { notificationcell *cell = (notificationcell *)[tableview dequeuereusablecellwithidentifier:@"cell"]; if (cell == nil) { nsarray *ary = [[nsbundle mainbundle]loadnibnamed:@"notificationcell" owner:self options:nil]; cell = [ary objectatindex:0]; } nsmutabledictionary *dict = [[nsmutabledictionary alloc] initwithdictionary:[notificationarray objectatindex:indexpath.section]]; cell.title_lbl.text=[dict objectforkey:@"event_title"]; cell.description_lbl.text=[dict objectforkey:@"description"]; [cell.description_lbl sizetofit]; [cell sizetofit]; return cell; }
for need follow steps.
step 1
use autolayout in storyboard or .xib , make sure constrains label dynamic should this.
step 2
on viewdidload of viewcontroller have provide estimatedrowheight this.
self.tblviewoutlet.rowheight = uitableviewautomaticdimension; self.tblviewoutlet.estimatedrowheight = 50.0; //any height minimum step 3
and in tableview delegate heightforrowatindexpath,
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return uitableviewautomaticdimension; } make sure uilabel (here guess description_lbl)of prototype cell property numberoflines should 0.
hope works you. :)
happy coding!!


Comments
Post a Comment