title: Swift: UIView appear in UITableView cell
body: <p>Im having an issue putting a UIView that I created in a specific UITableView cell. Here is my code:</p>
  
  <pre><code>class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
  
  //MARK : Properties
  var tableView = UITableView()
  var items: [String] = ["Age", "Gender", "Smoking Hx", "Occup. -Ag", "Family Hx", "Chronic Lung Disease Radiology", "Chronic Lung Disease Hx", "Nodule Border", "Nodule Location", "Satellite Lesions", "Nodule Pattern Cavity", "Nodule Size"]
  var navigationBar = NavigationBar()
  var gender = GenderView()
  var maleIcon = MaleIconView()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      //Create TableView
      tableView.frame = CGRectMake(0, self.view.bounds.height * 0.097, self.view.bounds.width,
          self.view.bounds.height - self.view.bounds.height * 0.097);
      tableView.delegate = self
      tableView.dataSource = self
      tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
      self.view.addSubview(tableView)
  
  
  
      //Create Navigation Bar with custom class
      self.navigationBar = NavigationBar(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height * 0.097))
      self.view.addSubview(navigationBar)
  
  }
  
  
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  
  
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return self.items.count
  }
  
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
  
      cell.textLabel?.text = self.items[indexPath.row]
  
      //Cell wont turn grey when selected
      cell.selectionStyle = UITableViewCellSelectionStyle.None
  
      //Want to add UIView male Icon in first row
      if(indexPath.row == 0){
          maleIcon = MaleIconView(frame: CGRect(x: 0, y: 0, width: 55, height: 55))
          maleIcon.center.x = cell.center.x + cell.center.x * 0.5
          maleIcon.center.y = cell.contentView.center.y
          maleIcon.layer.cornerRadius = 0.5 * maleIcon.bounds.size.width
          //maleIcon.layer.borderWidth = 3.0
          cell.addSubview(maleIcon)
      }
  
  
      return cell
  
  }
  
  func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
  
   return self.view.bounds.height * 0.15
  
  }
  
  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      print("You selected cell #\(indexPath.row)!")
  
  }
  }
  </code></pre>
  
  <p>Maybe the issue exists within the MaleIconView()? Here is the code to that:</p>
  
  <pre><code>class MaleIconView: UIView {
  
  var maleView = UIView()
  
  override init(frame: CGRect) {
      super.init(frame: frame)
      self.frame = frame
      setUpView()
  }
  
  func setUpView(){
  
      maleView.frame = CGRectMake(0, 0, self.bounds.width, self.bounds.height)
      maleView.alpha = 1
      maleView.backgroundColor = UIColor.blackColor()
      maleView.layer.cornerRadius = 0.5 * maleView.bounds.size.width
      self.addSubview(maleView)
  
  }
  
  
  
  func hide(){
      self.removeFromSuperview()
  }
  
  required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  
  }
  </code></pre>
  
  <p>Im trying to get the UIView to appear on the right side of the cell 0. There is also this issue where the indexPath's are all off, i think this could be of some issue to why the UIView appears in multiple cells. Thank you in advance!</p>