title: Using UITableViewDataSource with Custom Cells Having Subviews
body: <p>When using a custom cell in a UITableView I am getting a strange table overlap:</p>
  <p><strong>Problem</strong></p>
  <ul>
  <li>scroll down &amp; last  two rows have top  two rows painted over them!</li>
  <li>scroll up   &amp; first two rows have bott two rows painted over them!</li>
  </ul>
  <p>Here is the code for the UITableViewDataSource:</p>
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      let cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier(&quot;cell&quot;) as UITableViewCell!;
  
      let cellText:String = self.items[indexPath.row];
  
      let subjectField:UILabel = UILabel(frame: CGRect(x:55, y: 25, width: 303, height:  25));
      
      subjectField.text = cellText;
      
      //cell.textLabel?.text = cellText;    //works fine!
      cell.addSubview(subjectField);        //fails  XX(!
      
      return cell;
  }
  </code></pre>
  <p>Here is a screenshot:</p>
  <ul>
  <li><em>Note</em>: '0  9' and '1  A' are the paint overs!</li>
  <li><em>Ref</em>:  '0  9' is row#0 ('0   ') and row#9 ('   9')</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/mkIQH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mkIQH.png" alt="enter image description here" /></a></p>
  <p><strong>Question</strong></p>
  <ul>
  <li>Why does adding the subview cause the paint issue?</li>
  <li>What is the correct way to paint custom views into the cell?</li>
  </ul>
  <p><strong>Context</strong></p>
  <ul>
  <li>My actual originating code uses custom cells in a custom tableview</li>
  <li>This code example here is a condensed version of the originating code. I can post whatever is needed to help resolve this!</li>
  </ul>