i've vc lets call "detailsvc" tableview have rows different height.
the "detailsvc" added subview vc called "mainvc"
in "detailsvc"
- (void)viewdidload { [super viewdidload]; self.automaticallyadjustsscrollviewinsets = yes; [self.tableview registerclass:[uitableviewcell class] forcellreuseidentifier:cellidentifier]; self.tableview.rowheight = uitableviewautomaticdimension; } - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; [self.navigationcontroller setnavigationbarhidden:no animated:animated]; } - (void)viewdidlayoutsubviews { [super viewdidlayoutsubviews]; self.tableviewheightconstraint.constant = self.tableview.contentsize.height; [self.tableview needsupdateconstraints]; cgfloat containerheight = cgrectgetheight(self.tableview.bounds) + self.addresslabelheightconstraint.constant; [self.tableviewdelegate punchdetailscontroller:self didupdatetableviewwithheight:containerheight]; [self.contentview layoutifneeded]; } - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{ return uitableviewautomaticdimension; } - (cgfloat)tableview:(uitableview *)tableview estimatedheightforrowatindexpath:(nsindexpath *)indexpath{ return uitableviewautomaticdimension; }
this works in ios 8 , above , doesn't work in ios 7 or 7.1
the tableview's height coming out 0 , doens't display tableview @ all.
i understand "uitableviewautomaticdimension" part of ios 8 , not available in ios 7.
what other approach should use work both ios 7 , ios 8.
my issue similar https://stackoverflow.com/questions/29425782/ios7-0-and-ios-7-1-doesnt-honor-dynamic-tableview-height
i think you'll have check os version , lower 8, calculate height of cell manually , return it. also, performance reasons, ios 7 return constant, or don't implement estimatedheightforrowatindexpath
z.
Comments
Post a Comment