Cell Tap Doesn't Work on didSelectRowAtIndexPath

1.2k Views Asked by At

I'm using Parse.com to build my app.

I initialized a PFQueryTableViewController as my subclass.

I'm unable to tap the indexPath.row so that the cell leads to another viewController and passes data.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

       print("tapped")
        //Nothing prints. The simulator cell doesn't even change color as it normally does... 

}

In a normal project without Parse, I tap and it leads me to where I want it to lead. I don't understand why that doesn't work here.

I referenced several links, such as:

  1. https://www.parse.com/questions/pfquerytableview-didselect-row-open-pbobject-in-uiwebview (outdated and objective-c)
  2. https://www.parse.com/questions/using-pfquerytableviewcontroller-in-detail-view (didn't work)
  3. didSelectRowAtIndexPath method at PFQueryTableViewController (also didn't work)

None have helped.

Im also trying to use a UIGestureecognizer on the view from the custom cell. This isn't helping either...

This is the attributes inspector:

http://postimg.org/image/3omx3serh/

I've selected and deselected the relevant parts. Nothing works.

EDIT: I'm also using an initializer:

 override init(style: UITableViewStyle, className: String!)
    {
        super.init(style: style, className: className)

        self.pullToRefreshEnabled = true
        self.paginationEnabled = false
        self.objectsPerPage = 25

        self.parseClassName = className
        self.tableView.rowHeight = 120
        self.tableView.allowsSelection = false
    }

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

Any idea why I can't tap cell? Any ideas on how to tap the cell?

2

There are 2 best solutions below

0
Lukesivi On BEST ANSWER

I'm also using an initializer that I'm accessing. This PFTableViewController I'm building only in code. For those building in code and not in the storyboard, make sure self.tableView.allowsSelection = true. Saw other links experiencing similar problems. Here the full code of the initializer:

override init(style: UITableViewStyle, className: String!)
{
    super.init(style: style, className: className)

    self.pullToRefreshEnabled = true
    self.paginationEnabled = false
    self.objectsPerPage = 25

    self.parseClassName = className
    self.tableView.rowHeight = 120
    self.tableView.allowsSelection = true
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

Realized that self.tableView.allowsSelection = false was set to false instead of true.

I set it to true and now it works.

1
TekMi On

Firstly I would check if your Table View has "User Interaction Enabled" enabled inside Attribute Inspector.

Secondly I would examine which class has been inserted inside your View Controller's Identity Inspector.