title: Custom tableHeaderView with snapkit?
body: <p>I have a custom view that assign to tableHeaderView. I used snapkit to made  custom view layout. I have run some errors, I don't know how to solve it . Please help me, Thanks. Here is my code:</p>
  
  <p>In my ViewController:</p>
  
  <pre><code>class QuestionDetailController: BaseViewController {
  
  lazy var tableView = DefaultManager.createTableView()
  lazy var dataSource: [HomeListItemModel] = []
  lazy var hearderView: QuestionDetailHearderView = QuestionDetailHearderView()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      setupTableView()
      navigationItem.title = "问题详情"
  }
  
  func setupTableView() {
      view.addSubview(tableView)
      tableView.estimatedRowHeight = 100
      tableView.rowHeight = UITableViewAutomaticDimension
      tableView.setDelegate(self,self)
      tableView.tableHeaderView = hearderView
      registerCell()
  }
  
  override func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()
      tableView.snp.makeConstraints { (make) in
          make.left.right.top.bottom.equalToSuperview()
      }
      tableView.sizeHeaderToFit()
  }
  
  func registerCell() {
      tableView.register(LargeImageViewCell.self, forCellReuseIdentifier: LargeImageViewCell.idenfitier)
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
     }
   }
  
  extension QuestionDetailController: UITableViewDelegate, UITableViewDataSource {
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return 10
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let large = tableView.dequeueReusableCell(withIdentifier: LargeImageViewCell.idenfitier, for: indexPath) as! LargeImageViewCell
      large.titleLabel.text = "hello"
      return large
     }
   }
  </code></pre>
  
  <p>The extension of UITableView contain sizeHeaderToFit():</p>
  
  <pre><code>extension UITableView{
  
  func sizeHeaderToFit() {
      if let headerView = self.tableHeaderView {
          let height = headerView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height
  
          var newFrame = headerView.frame
          newFrame.size.height = height
          headerView.frame = newFrame
  
          headerView.layoutIfNeeded()
      }
   }
  }
  </code></pre>
  
  <p>My custom view like this:</p>
  
  <pre><code>class QuestionDetailHearderView: UIView {
  
  lazy var tagView: TagView = TagView()
  lazy var questionLabel = UILabel().then {
      $0.setLabel(AppTheme.Colors.title, 19.5)
      $0.withNumberOfLines(0)
  }
  lazy var contentLabel = UILabel().then {
      $0.setLabel(AppTheme.Colors.content3, 14.5)
  }
  lazy var threeImageView: ThreeImageView = ThreeImageView()
  lazy var answerLabel = UILabel().then {
      $0.setLabel(AppTheme.Colors.auxiliary2, 14.5)
  }
  
  override init(frame: CGRect) {
      super.init(frame: frame)
      setupUI()
  }
  
  required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  
  func setupUI() {
      addSubview(tagView)
      addSubview(questionLabel)
      addSubview(contentLabel)
      addSubview(threeImageView)
      addSubview(answerLabel)
      addUIConstraints()
  }
  
  func addUIConstraints() {
      tagView.snp.makeConstraints { (make) in
          make.left.equalToSuperview().offset(AppDefaults.Constants.space13)
          make.right.equalToSuperview().offset(-AppDefaults.Constants.space13)
          make.top.equalToSuperview().offset(AppDefaults.Constants.space16)
          make.height.equalTo(30)
      }
  
      tagView.backgroundColor = UIColor.yellow
  
      questionLabel.snp.makeConstraints { (make) in
          make.left.right.equalTo(tagView)
          make.top.equalTo(tagView.snp.bottom).offset(AppDefaults.Constants.space15)
      }
      questionLabel.backgroundColor = UIColor.red
  
      contentLabel.snp.makeConstraints { (make) in
          make.left.right.equalTo(questionLabel)
          make.top.equalTo(questionLabel.snp.bottom).offset(AppDefaults.Constants.space13)
      }
      contentLabel.backgroundColor = UIColor.cyan
  
      threeImageView.snp.makeConstraints { (make) in
          make.left.right.equalTo(contentLabel)
          make.top.equalTo(contentLabel.snp.bottom).offset(AppDefaults.Constants.space13)
          make.height.equalTo(77)
      }
  
      answerLabel.snp.makeConstraints { (make) in
          make.left.right.equalTo(threeImageView)
          make.top.equalTo(threeImageView.snp.bottom).offset(AppDefaults.Constants.space13)
          make.bottom.equalToSuperview().offset(-AppDefaults.Constants.space16)
      }
      answerLabel.backgroundColor = UIColor.cyan
  
     // updateData()
  }
  }
  </code></pre>
  
  <p>Here is some part of the error:</p>
  
  <pre><code> [LayoutConstraints] Unable to simultaneously satisfy constraints.
  Probably at least one of the constraints in the following list is one you don't want. 
  Try this: 
      (1) look at each constraint and try to figure out which you don't expect; 
      (2) find the code that added the unwanted constraint or constraints and fix it. 
  (&lt;SnapKit.LayoutConstraint:0x1740b5ae0@QuestionDetailHearderView.swift#47 ZhiMa_iOS.TagView:0x103850290.left == ZhiMa_iOS.QuestionDetailHearderView:0x10384fed0.left + 13.0&gt;",
  "&lt;SnapKit.LayoutConstraint:0x1740b7e20@QuestionDetailHearderView.swift#48 ZhiMa_iOS.TagView:0x103850290.right == ZhiMa_iOS.QuestionDetailHearderView:0x10384fed0.right - 13.0&gt;",
  "&lt;NSLayoutConstraint:0x17009fcc0 'UIView-Encapsulated-Layout-Width' ZhiMa_iOS.QuestionDetailHearderView:0x10384fed0.width == 0   (active)&gt;"
   )
  
    Will attempt to recover by breaking constraint 
       &lt;SnapKit.LayoutConstraint:0x1740b7e20@
      QuestionDetailHearderView.swift#48 
        ZhiMa_iOS.TagView:0x103850290.right == 
        ZhiMa_iOS.QuestionDetailHearderView:0x10384fed0.right - 13.0&gt;
   Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to 
   catch this in the debugger.
   The methods in the UIConstraintBasedLayoutDebugging category on UIView 
   listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>