cellForNextPageAtIndexPath在swift2不可见(cellForNextPa

2019-10-24 15:07发布

我从解析实现PFQueryTableViewController与部分和分页。 因为我使用的部分,我需要设置“负载更多的”细胞对我自己的。 然而,看来我无法访问方法cellForNextPageAtIndexPath - 我得到一个错误:“” UITablView“没有一个会员名“cellForNextPageAtIndexPath”。

我环顾四周,并在主题的唯一资源似乎是这个悬而未决的问题: cellForNextPageAtIndexPath在迅速

这里是我的代码:

override func tableView(tableView: UITableView, cellForNextPageAtIndexPath indexPath: NSIndexPath) -> PFTableViewCell? {
    return PFTableViewCell()
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFTableViewCell? {


    let objectId = objectIdForSection((indexPath.section))
    let rowIndecesInSection = sections[objectId]!
    let cellType = rowIndecesInSection[(indexPath.row)].cellType
    var cell : PFTableViewCell


    if (indexPath.section == self.objects?.count) {
        cell = tableView.cellForNextPageAtIndexPath(indexPath) //'UITablView' does not have a member name 'cellForNextPageAtIndexPath'
    }


    switch cellType {
    case "ImageCell" :
        cell = setupImageCell(objectId, indexPath: indexPath, identifier: cellType)
    case "PostTextCell" :
        //cell = setupImageCell(objectId, indexPath: indexPath, identifier: "ImageCell")
        cell = setupTextCell(objectId, indexPath: indexPath, identifier: cellType)
    case "CommentsCell" :
        cell = setupCommentsCell(objectId, indexPath: indexPath, identifier: cellType)
    case "UpvoteCell" :
        cell = setupUpvoteCell(objectId, indexPath: indexPath, identifier: cellType)
    case "DividerCell" :
        cell = setupDividerCell(indexPath, identifier: cellType)
    default : print("unrecognised cell type")
        cell = PFTableViewCell()
    }
    cell.selectionStyle = UITableViewCellSelectionStyle.None

    return cell
}

Answer 1:

我知道这是有点晚了,但我想通了这一点,并希望分享对未来的访客。

如果你想定制一贯的“加载更多......”在解析分页电池,请执行以下操作:

1)创建子类PFTableViewCell一个新的类。 对于我们的演示目的,我们将其称之为PaginationCell。

2)更换所有与下面的PaginationCell类的内容:

  import UIKit
  import Parse
  import ParseUI


 class PaginateCell: PFTableViewCell {



 override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: "paginateCell")


}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!
}

以上我们只是初始化的细胞具有的reuseIdentifier“paginateCell。” 这种编程方式设置reuseIdentifier。

3)在你的PFQueryTableViewController,实现以下方法:

   override func tableView(tableView: UITableView, cellForNextPageAtIndexPath indexPath: NSIndexPath) -> PFTableViewCell? {


}

3)创建一个笔尖文件。 对于我们的演示目的,我会打电话给该文件paginateCellNib.xib。 然而设计你想要的自定义单元格。 一定要设置单元格reuseIdentifier,使之符合上述之一。 自定义类设置为我们在上面创建的PaginationCell类,以及所有IBoutlets连接到这个班级。

4)现在,代替上述具有以下内容的cellForNextPageAtIndexPath的内容:

    override func tableView(tableView: UITableView, cellForNextPageAtIndexPath indexPath: NSIndexPath) -> PFTableViewCell? {

    // register the class of the custom cell  
    tableView.registerClass(PaginateCell.self, forCellReuseIdentifier: "paginateCell")
    //register the nib file the cell belongs to
    tableView.registerNib(UINib(nibName: "paginateCellNib", bundle: nil), forCellReuseIdentifier: "paginateCell")

    //dequeue cell
    let cell = tableView.dequeueReusableCellWithIdentifier("paginateCell") as! PaginateCell

    cell.yourLabelHere.text = "your text here"





    return cell
}


文章来源: cellForNextPageAtIndexPath not visible in swift2