PFQueryTableViewController语言 - CellForRowAtIndexPath 未被调用/不工作



我一直在尝试实现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
}
*/
}

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

最新更新