ios - UITableViewCell auto-sizing height not working -
the cells in table view not auto-sizing height contain content. using "basic" style cell prototype. created new test project containing view controller , storyboard , has same issue. doing wrong?
rowheighttestcontroller:
@implementation rowheighttestcontroller #pragma mark - table view data source - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { // return number of sections. return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // return number of rows in section. return 2; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"test" forindexpath:indexpath]; // configure cell... cell.textlabel.text = @"testing"; cell.textlabel.font = [uifont systemfontofsize:60 + indexpath.row]; return cell; } @end
the storyboard:
what seeing:
try set properties of table :
tableview.estimatedrowheight = 44.0; tableview.rowheight = uitableviewautomaticdimension;
if content change use notification reload table
- (void)viewdidappear:(bool)animated { [super viewdidappear:animated]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(contentsizecategorychanged:) name:uicontentsizecategorydidchangenotification object:nil]; } - (void)viewdiddisappear:(bool)animated { [super viewdiddisappear:animated]; [[nsnotificationcenter defaultcenter] removeobserver:self name:uicontentsizecategorydidchangenotification object:nil]; } // method called when dynamic type user setting changes (from system settings app) - (void)contentsizecategorychanged:(nsnotification *)notification { [self.tableview reloaddata]; }
for more watch great answer : https://stackoverflow.com/a/18746930/3202193
Comments
Post a Comment