0

我正在使用 Parse.com 构建我的应用程序。

我将 a 初始化PFQueryTableViewController为我的子类。

我无法点击 indexPath.row 以便单元格指向另一个 viewController 并传递数据。

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

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

}

在一个没有 Parse 的普通项目中,我点击它,它会引导我到我想要它引导的地方。我不明白为什么这在这里不起作用。

我引用了几个链接,例如:

  1. https://www.parse.com/questions/pfquerytableview-didselect-row-open-pbobject-in-uiwebview(过时和objective-c)
  2. https://www.parse.com/questions/using-pfquerytableviewcontroller-in-detail-view(没用)
  3. PFQueryTableViewController 的 didSelectRowAtIndexPath 方法(也没有工作)

没有人有帮助。

我还尝试在自定义单元格的视图上使用 UIGestureecognizer。这也无济于事...

这是属性检查器:

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

我已选择和取消选择相关部分。没有任何效果。

编辑:我也在使用初始化程序:

 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")
}

知道为什么我不能点击单元格吗?关于如何点击单元格的任何想法?

4

2 回答 2

1

首先,我会检查您的表视图是否在属性检查器中启用了“启用用户交互”。

其次,我将检查在您的视图控制器的身份检查器中插入了哪个类。

于 2015-11-10T16:38:53.943 回答
1

我还使用了我正在访问的初始化程序。这个 PFTableViewController 我只在代码中构建。对于那些在代码中而不是在故事板中构建的人,请确保self.tableView.allowsSelection = true. 看到其他链接遇到类似问题。这里是初始化程序的完整代码:

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")
}

意识到self.tableView.allowsSelection = false设置为假而不是真。

我将其设置为 true,现在它可以工作了。

于 2015-11-10T18:11:52.197 回答