【问题标题】:PFQueryTableViewController loading one row with includeKeyPFQueryTableViewController 用 includeKey 加载一行
【发布时间】:2015-09-03 03:07:52
【问题描述】:

我正在使用 includeKey 从我的 PFObject 中的数组列中加载多个值。但是,当我导航到 tableView 时,tableView 只加载一行

这是因为 Parse cellForRowAtIndexPath 方法只被调用一次(当它应该被调用以获取“以下”数组中的值的数量时)

这是我的实现

override func queryForTable() -> PFQuery {
    let query = PFQuery(className: "Followers")
    query.whereKey("username", equalTo: username)
    query.includeKey("following")

    return query
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
    let cell = tableView.dequeueReusableCellWithIdentifier(identifier) as! AccountQueryCell
    let followerObject = object as! PFFollowers

    cell.usernameLabel.text = followerObject.getFollowing()[indexPath.row]
    cell.profileImage.username = followerObject.getFollowing()[indexPath.row]

    return cell
}

如您所见,我返回一个包含“以下”数组的查询。

我的 Parse "Followers" 类包含以下自定义列:"following" (Array) 和 "username" (String)

有人可以向我解释为什么我的查询没有为以下数组中的每个值调用 cellForRowAtIndexPath 吗?

【问题讨论】:

    标签: ios uitableview parse-platform


    【解决方案1】:

    我认为问题在于您正在查询与单个用户名匹配的所有 Followers 对象。根据您的数据模型的描述,这将导致仅找到一个对象。

    PFQueryTableViewController 根据查询结果自动设置表格视图的数据源。换句话说,表格视图被设置为只创建一个单元格来对应查询的一个结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多