I have a UITableView that has five static cells. I need the cell height of one cell to adjust automatically to its contents, which is one UILabel.
Is there any way I can use..
tableView.estimatedRowHeight = 42.0
tableView.rowHeight = UITableViewAutomaticDimension
..for a table view with static cells, or does this only work for table views with dynamic prototype cells?
(Or is there any other way of doing this that you would recommend?)
Additional info
The UITableView is in a TableViewController which is embedded into a Container View.
The five static cells are quite different from one another and are only used in one app scene, so I don't see much point in going for dynamic prototypes and custom cell subclasses.
I update the tableview like this
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[_myTableView reloadData];
}
I add constraints to the UILabel as described here:
http://www.appcoda.com/self-sizing-cells/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…