title: parse tableview controller added to parent view will not select cells in Swift
body: <p>I have a view controller, and when pressing a button I want it to display a tableview on top of the view controller.  I have used the following code for my view controller:</p>
  
  <pre><code>    @IBAction func addRecipientsButton(sender: AnyObject) {
      let controller:contactTableView =         self.storyboard!.instantiateViewControllerWithIdentifier("contactTableView") as! contactTableView
      controller.view.frame = CGRectMake(10,100,300,400)
      controller.view.layer.cornerRadius = 30
      controller.willMoveToParentViewController(self)
      self.view.addSubview(controller.view)
      self.addChildViewController(controller)
      controller.didMoveToParentViewController(self)
      }
  </code></pre>
  
  <p>And here is the code for my table view controller:</p>
  
  <pre><code>    import Foundation
      import Parse
      import UIKit
      import CoreData
  
      class contactTableView: PFQueryTableViewController {
  @IBAction func doneButton(sender: AnyObject) {
      self.willMoveToParentViewController(nil)
      self.view.removeFromSuperview()
      self.removeFromParentViewController()
  }
  
  let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
  var RecipientArray: Array &lt;String&gt; = []
    var avatarView: AvatarView!
  var error: NSError?
  var lastSelection: NSIndexPath!
  
  enum Error: ErrorType {
      case failed
      case Short
  }
  
  // Initialise the PFQueryTable tableview
  override init(style: UITableViewStyle, className: String!) {
      super.init(style: style, className: className)
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  
  
      // Configure the PFQueryTableView
      self.parseClassName = "Contact"
      self.textKey = "UserID"
      self.pullToRefreshEnabled = true
      self.paginationEnabled = false
  }
  
  // Define the query that will provide the data for the table view
  override func queryForTable() -&gt; PFQuery {
      let query = PFQuery(className:"Contact")
      query.whereKey("UserID", equalTo: PFUser.currentUser()!)
      query.includeKey("ContactID")
      return query
  }
  
  
  //override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject!) -&gt;
      crewViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! crewViewCell!
          //if cell == nil {
          //    cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")
          //}
  
          tableView.tableFooterView = UIView(frame: CGRectZero)
  
  
  
          // Extract values from the PFObject to display in the table cell
          let object2 = object["ContactID"] as! PFObject
          object2.fetchIfNeededInBackgroundWithBlock {
              (post: PFObject?, error: NSError?) -&gt; Void in
  
          }
          let picquery = PFQuery(className: "_User")
          picquery.whereKey("objectId", equalTo: object2["UserID"]!)
          picquery.findObjectsInBackgroundWithBlock {
              (objects:[AnyObject]?,error:NSError?) -&gt; Void in
              if error == nil {
                  let imagesobjects = objects as! [PFObject]
  
                  for object : PFObject in objects as! [PFObject] {
                      let image = object["UserPic"] as! PFFile?
  
                      image?.getDataInBackgroundWithBlock {
                          (imageData:NSData?, error:NSError?) -&gt; Void in
                          if error == nil {
                              if let imageData = imageData {
                                  let image = UIImage(data:imageData)
  
                                  self.avatarView = AvatarView(image: image!)
                                  self.avatarView.center = CGPointMake(40, 35)
                                  self.avatarView.bounds = CGRectMake(0, 0, 60, 60)
                                  cell.addSubview(self.avatarView)
  
         // cell.contactPic?.image = image
          cell.nameLabel?.text = object2["FirstName"] as! String
          cell.nameLabel?.textColor = self.getRandomColor()
          cell.jobLabel?.text = object2["LastName"] as! String
          cell.jobLabel?.textColor = self.getRandomColor()
  
  
                                                        }
                      }
                  }
              }
          }
          }
          return cell
  }
  
  override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      if let indexPath = self.tableView.indexPathForSelectedRow {
          //let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! crewViewCell!
           let selectedCell = tableView.cellForRowAtIndexPath(indexPath)!
          let row = Int(indexPath.row)
          //let currentObject = objects?[row] as! PFObject
  
          let obj: PFObject! = self.objectAtIndexPath(indexPath)
  
          if selectedCell.accessoryType == .None {
              let object2 = obj["ContactID"] as! PFObject
              object2.fetchIfNeededInBackgroundWithBlock {
                  (post: PFObject?, error: NSError?) -&gt; Void in
  
  
  
              var RecipientString: String = object2["UserID"]! as! String
              self.RecipientArray.append(RecipientString as String)
              print(obj["ContactID"])
  
              let entityDescription =
              NSEntityDescription.entityForName("Recipients",
                  inManagedObjectContext: self.managedObjectContext!)
  
              let recipient = Recipients(entity: entityDescription!,
                  insertIntoManagedObjectContext: self.managedObjectContext)
  
              recipient.recipient = RecipientString
              print("Recipient Saved")
  
              recipient.rownumber = indexPath.row as Int
  
              do{
                  try! self.managedObjectContext?.save()
              } catch {
  
              }
              selectedCell.accessoryType = .Checkmark
  
              }
          }else {
              let object2 = obj["ContactID"] as! PFObject
              object2.fetchIfNeededInBackgroundWithBlock {
                  (post: PFObject?, error: NSError?) -&gt; Void in
         // if selectedCell.accessoryType == .Checkmark {
              var RecipientString: String = object2["UserID"]! as! String
              let i = self.RecipientArray.indexOf(RecipientString)
              self.RecipientArray.removeAtIndex(i!)
  
              let fetchRequest = NSFetchRequest(entityName: "Recipients")
              fetchRequest.includesSubentities = false
              fetchRequest.returnsObjectsAsFaults = false
  
              fetchRequest.predicate = NSPredicate(format:"recipient == %@", RecipientString)
              var items = []
              var error: NSError?
              let moc = self.managedObjectContext
              // moc is your NSManagedObjectContext here
              try! items = moc!.executeFetchRequest(fetchRequest)
  
              for recipient in items {
                  moc!.deleteObject(recipient as! NSManagedObject)
                  print("Recipient Deleted")
              }
  
              try! self.managedObjectContext?.save()
              selectedCell.accessoryType = .None
          }
  
      }
  
          }
  }
  
  
  
  
  
  
  func getRandomColor() -&gt; UIColor{
      let randomRed:CGFloat = CGFloat(drand48())
      let randomGreen:CGFloat = CGFloat(drand48())
      let randomBlue:CGFloat = CGFloat(drand48())
  
      return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)
  }
  
  
  
      }
  </code></pre>
  
  <p>When I run this, the table displays how it should, and I can close the table again and use my initial view control.  But I cannot select any table cells.  The table has the data source and delegate setup as it should do to the 'contactTableView' file.  And if I link a modal segue to the table rather than systematically calling it, I can select the cells and this works how it should do.  </p>
  
  <p>But currently I would like to systematically call this on top of my current view and be able to select cells.</p>
  
  <p>If anybody has any pointers on what I have missed I would appreciate it.</p>
  
  <p>Thanks</p>