Why is it that the contents of the cell in tableView are not displayed correctly when it first enters, but it is displayed normally when it is clicked?

  ios, question

Why is it that the contents of the cell in tableView are not displayed correctly when it first enters, but it is displayed normally once clicked?

I subclassed a tableView, and then encapsulated a tableViewcell with xib. There are controls to be displayed in tableView, but the position and size of the controls are set according to model in tableViewCell’s setLayoutSubviews. The result is that when not clicked, the displayed position is the position inside xib, and then after clicked, the position I set in layoutSubviews

I subclassed a tableView, and then encapsulated a tableViewcell with xib. There are controls to be displayed in tableView, but the position and size of the controls are set according to model in tableViewCell's setLayoutSubviews.  The result is that when not clicked, the displayed position is the position inside xib, and then after clicked, the position I set in layoutSubviews
  1. tableViewcellWith or without encapsulation, the height is determined bytableViewThe decision was made before you realized it.- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPathIn the case of callback, tableView’s RowHeight is fixed at 44, and you use xib, so the height in xib will be the first to be loaded.

  2. The layout problem mentioned in the question should be confirmedsetLayoutSubviewsWhether this method is called after the model is passed, the topic owner may uselayoutSubviewsMethod, orsetNeedsLayout? It is not clear, but according to the description, after clickinglayoutSubviewsThe method is to be called, at this time the model must have been bound, so the position is correct. (guess only)