title: Dynamically update an ImageView in a tableview section
body: <p>I have a table view with 2 (or more) sections. I have added an ImageView into it and need to change the image view according the values which are containing in an array at the beginning and when selecting/deselecting a cell. I created the view as follows,</p>
  
  <pre><code>func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      let viewHeader = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 40))
      buttonCheck = UIButton(type: .custom)
      buttonCheck!.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
      buttonCheck!.tag = section
      buttonCheck!.addTarget(self, action: #selector(tapSection(sender:)), for: .touchUpInside)
      viewHeader.addSubview(buttonCheck!)
  }
  </code></pre>
  
  <p>This adds the ImageView fine and when I load the table data initially, I need to set the image view programatically. To change the image view I did,</p>
  
  <pre><code>if tableViewData.contains(where: self.tags.contains) {
     buttonCheck!.setImage(UIImage(named: "CheckmarkCircle"), for: .normal)
  } else {
     buttonCheck!.setImage(UIImage(named: "DeselectedCheckmarkCircle"), for: .normal)
  }
  </code></pre>
  
  <p>I called this inside <code>didSelectRowAt</code> and <code>didDeselectRowAt</code> method. The problem here is, When I select a cell from section one(section = 0), it affects to the second section(section = 1) header image view. In other work when I select a cell from section one the second section's header image is changing. How may I fix this? </p>