【问题标题】:PFQueryTableViewController - CellForRowAtIndexPath is not being called/is not workingPFQueryTableViewController - CellForRowAtIndexPath 没有被调用/不工作
【发布时间】:2017-02-10 02:14:00
【问题描述】:

我一直在尝试实现一个 PFQueryTableViewController,以便向用户显示来自我的 Parse 服务器的数据。无论出于何种原因,我的自定义原型单元根本没有被使用。相反,表格只是显示(x 代表数字)。我已经检查以确保我的所有插座都正确连接,并且重用标识符与我在情节提要中设置的标识符相对应。不确定问题可能是什么。我的 PFQueryTableViewController 和 PFTableViewCell 代码如下。如果有人可以帮助我,我将不胜感激。

PFQueryTableViewController 类:

import UIKit
import ParseUI
import Parse

class HomePagePFQueryTable: PFQueryTableViewController {



override func queryForTable() -> PFQuery<PFObject>
{
    let query = PFQuery(className: "Posts")
    //query.cachePolicy = .cacheElseNetwork
    query.order(byDescending: "createdAt")
    return query
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell?
{
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath) as! HomePagePFQueryTableCell

    cell.titleLabel?.text = object?.object(forKey: "Title") as? String

    let imageFile = object?.object(forKey: "imageFile") as? PFFile
    print(cell.titleLabel.text)
    cell.mainImageView?.file = imageFile

    cell.mainImageView.loadInBackground()

    return cell
}




override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    print("Loaded")
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

PFTableViewCell 类:

import UIKit
import Parse
import ParseUI

class HomePagePFQueryTableCell: PFTableViewCell {
@IBOutlet weak var mainImageView: PFImageView!

@IBOutlet weak var titleLabel: UILabel!
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
    // Drawing code
}
*/

}

【问题讨论】:

    标签: ios swift parse-platform pfquerytableviewcontrolle


    【解决方案1】:

    哇,刚刚想通了。我所要做的就是在 cellForRowAtIndexPath 函数的第一个 tableView 前面放置一个_

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多