title: UITableViewCell with Custom View
body: <p>i am desperately trying to add a custom View to a UITableViewCell. I have a UITableViewController in Storyboard wich is linked to a TestTableViewController Class and the prototype cell has the identifier "Cell2". </p>
  
  <p>So this is the code in UITableViewController:</p>
  
  <pre><code>    override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      // #warning Incomplete implementation, return the number of sections
      return 1
  }
  
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      // #warning Incomplete implementation, return the number of rows
      return dataArray.count
  }
  
  override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
      return 190
  }
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      let cell = tableView.dequeueReusableCellWithIdentifier("Cell2", forIndexPath: indexPath)
      let data = dataArray[indexPath.row]
  
      let ticket = YellowTackleTicketComplete()
      ticket.frame = CGRect(x: 20, y: 20, width: 335, height: 150)
  
      cell.addSubview(ticket)
  
      //        cell.textLabel!.text = tackl!.valueForKey("title") as? String
      cell.backgroundColor = UIColor.clearColor()
      print(cell.subviews)
  
  
      return cell
  }
  </code></pre>
  
  <p>The dataArray is just for testing purposes and has one item in it. So what i get is a Table View with one empty cell. In the Xcode UI Debugger i can see the custom view. But its not shown in the simulator or on a device.</p>
  
  <p><a href="https://i.stack.imgur.com/YEjFL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YEjFL.png" alt="enter image description here"></a></p>
  
  <p>If anyone can help, thank you so much!</p>
  
  <p>This is the code of the view:</p>
  
  <pre><code>class YellowTackleTicketComplete: UIView {
  
  
      var containerView: UIView!
      var ticket: TacklTicket!
      var dropDownMenu: YellowDrawer!
      var dropDownBackground: YellowDrawerBackground!
      var ticketShadowLine: UIView!
  
  
      var lowAlphaView: UIView!
      var outbackButton: UIButton!
      var arrowView: UIView!
  
      var bounceHeight: CGFloat?
      var dropdownHeight: CGFloat?
      var topBorder: CGFloat?
      var bottomBorder: CGFloat?
      //let arrowLayer = CALayer()
      //let layerDelegate = LayerDelegate()
      var dropDownElements = [String]()
      var dropped = false
      var animating = false
      var delegate: YellowTackleTicketCompleteDelegate?
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          self.addObserver(self, forKeyPath: "highlighted", options: NSKeyValueObservingOptions.New, context: nil)
      }
  
      override init(frame: CGRect) {
          super.init(frame: frame)
          self.addObserver(self, forKeyPath: "highlighted", options: NSKeyValueObservingOptions.New, context: nil)
      }
  
      override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer&lt;Void&gt;) {
          self.setNeedsDisplay()
          if keyPath == "frame" {
              // Set up DropdownMenu
              self.dropDownBackground.frame.size.height = self.dropDownMenu.frame.maxY
          }
  
      }
  
      override func hitTest(point: CGPoint, withEvent event: UIEvent?) -&gt; UIView? {
          if(!self.clipsToBounds &amp;&amp; !self.hidden &amp;&amp; self.alpha &gt; 0.0){
              let subviews = self.subviews.reverse()
              for member in subviews {
                  let subPoint = member.convertPoint(point, fromView: self)
                  if let result:UIView = member.hitTest(subPoint, withEvent:event) {
                      return result;
                  }
              }
          }
          return nil
      }
  
      func ticketTapped() {
                  //if !animating {
          if !dropped {
              showDropdown()
              NSLog("#")
  //            NSLog("Scrolling to \((dropDownMenu.indexPathForSelectedRow?.row)!)(the index of the tableview selection)")
  //            dropDownMenu.scrollToRowAtIndexPath((dropDownMenu.indexPathForSelectedRow)!, atScrollPosition: .Middle, animated: false)
          } else {
              hideDropdown()
          }
          //        }
      }
  
      func showDropdown() {
          dropDownMenu.hidden = false
          self.ticket.drawShadowBeneathTicket()
          print("showing")
          if !animating {
              animating = true
              UIView.animateWithDuration(
                  1.0,
                  delay: 0,
                  usingSpringWithDamping: 0.7,
                  initialSpringVelocity: 0.5,
                  options: [],
                  animations: {
                      self.dropDownMenu.frame.origin.y  = self.bottomBorder!
  
                  }, completion: { _ in
                      //self.delegate?.menuOpen?()
                      self.animating = false
                      print(self.dropDownBackground.frame.size.height)
                      print(self.dropDownMenu.frame.maxY)
                  }
              )
          }
          self.setNeedsDisplay()
          self.dropDownMenu!.setNeedsDisplay()
          dropped = true
      }
  
      func hideDropdown() {
          if !animating {
              animating = true
              UIView.animateWithDuration(
                  0.7,
                  delay: 0,
                  usingSpringWithDamping: 0.7,
                  initialSpringVelocity: 0.5,
                  options: [],
                  animations: {
                      self.dropDownMenu.frame.origin.y  = self.topBorder! + self.bounceHeight!
                  }, completion: nil
              )
          }
          UIView.animateWithDuration(
              0.5,
              delay: 0,
              options: UIViewAnimationOptions.TransitionNone,
              animations: {
                  self.dropDownMenu.frame.origin.y  = self.topBorder! - self.dropdownHeight!
              }, completion: { _ in
                  //self.delegate?.menuClosed?()
                  self.animating = false
                  self.dropDownMenu.hidden = true
                  self.ticket.setNeedsDisplay()
                  self.setNeedsDisplay()
              }
          )
          dropped = false
      }
  
      func initSubViews() {
          self.topBorder = self.frame.height*6/150
          self.bottomBorder = self.frame.height - self.topBorder!
  
          self.bounceHeight = 250
          self.dropdownHeight = 350
  
          containerView = UIView()
          containerView.frame = CGRect(x: 0, y: topBorder!, width: self.bounds.width, height: dropdownHeight!+bounceHeight!)
          containerView.clipsToBounds = true
  
          ticket = TacklTicket()
          ticket.frame = self.bounds
          ticket.addTarget(self, action: #selector(YellowTackleTicketComplete.ticketTapped), forControlEvents: .TouchDown)
  
          dropDownMenu = YellowDrawer()
          dropDownMenu.frame =  CGRect(x: 0, y: topBorder! - dropdownHeight!, width: containerView.bounds.width, height: dropdownHeight!)
          dropDownMenu.hidden = true
          dropDownMenu.backgroundColor = UIColor.clearColor()
  
          dropDownMenu.addObserver(self, forKeyPath: "frame", options: .New, context: nil)
  
          dropDownBackground = YellowDrawerBackground()
          dropDownBackground.frame = CGRectMake(0,0,self.bounds.width,self.dropDownMenu.frame.maxY)
  
          self.addSubview(containerView)
          containerView.addSubview(dropDownBackground)
          containerView.addSubview(dropDownMenu)
          self.addSubview(ticket)
      }
  
  }
  </code></pre>