【问题标题】:PFQueryTableViewController crashes when "Load More" is tapped (pagination)点击“加载更多”时,PFQueryTableViewController 崩溃(分页)
【发布时间】:2017-02-09 18:34:10
【问题描述】:

我查看了类似的问题并尝试了不同的解决方案,但均无济于事。我已经在我的 iOS 应用程序中实现了 PFQueryTableViewController,并且我遵循了 Parse iOS 文档。一切正常,除了当我点击“加载更多”以获取下一个 x 数量的 Parse 对象时,应用程序崩溃并显示以下消息:

"*** -[__NSArrayM objectAtIndex:]: 索引 10 超出范围 [0 .. 9]"

我知道该消息的含义,但由于我使用的是 PFQueryTableViewController 而不是通常的 UITableViewController,我不确定如何解决此范围问题。

任何指导将不胜感激!

【问题讨论】:

    标签: swift parse-platform pagination pfquerytableviewcontrolle


    【解决方案1】:

    所以有兴趣的朋友,分页崩溃的原因是我实现了下面的方法,Parse文档上的例子没有。

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
    

    所以为了让你在不崩溃的情况下重新加载数据,需要实现以下代码:

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
        if indexPath.row <= (self.objects!.count - 1) {
    
          //These are the cells populated by your PFQuery objects
          //Do whatever you want to do with the selected cell  
    
        } else {
    
            //This is if the "Load More" cell is selected
    
            self.loadNextPage()
    
        }
    }
    

    【讨论】:

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