Autolayout + constraints for dynamic table height based on total rows

后端 未结 1 1247
北海茫月
北海茫月 2021-01-26 04:51

First of all this ain\'t about dynamic cell\'s height. So don\'t mix it up.

I have a scenario in that I created three cards

  1. Detail card:
1条回答
  •  囚心锁ツ
    2021-01-26 04:58

    I did not see any error in your constraints setup.

    You may see this UITemporaryLayoutHeight constraint because you added the contentSize observer ([self.tableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL] ) too soon in your view life cycle, which triggers a [self.tableView layoutIfNeeded].

    Try to add the observer in the viewDidLoad, remove it in dealloc of your View Controller ; Or in your viewWillAppear, and remove it in the viewWillDisappear for exemple.

    0 讨论(0)
提交回复
热议问题