Skip to content

Instantly share code, notes, and snippets.

@thornpig
Created February 2, 2016 20:57
Show Gist options
  • Save thornpig/215990f2f3f4349f41f1 to your computer and use it in GitHub Desktop.
Save thornpig/215990f2f3f4349f41f1 to your computer and use it in GitHub Desktop.
Force early layout with layoutIfNeeded if the some frame information is needed before the drawing cycle begins.
-(void)viewWillAppear:(BOOL)animated
{
//force the layout before the drawing cycle begins, so that when the tableview setup its cells the subviews of the cell
already have the frame information of the cell. For example, with this line, the text view inside the cell can use
the cell width to calculate depth to accormodate its text.
[self.view layoutIfNeeded];
[self.tableView reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment