我一直在尝试实现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
}
*/
}
答案 0 :(得分:0)
_
。