gpt4 book ai didi

ios - PFQueryTableViewController - CellForRowAtIndexPath 未被调用/不起作用

转载 作者:行者123 更新时间:2023-11-30 12:41:49 25 4
gpt4 key购买 nike

我一直在尝试实现 PFQueryTableViewController 以便向用户显示来 self 的 Parse 服务器的数据。无论出于何种原因,我的定制原型(prototype)单元根本没有被使用。相反,该表只是显示(x 代表数字)。我已检查以确保所有 socket 均已正确连接,并且重用标识符与我在 Storyboard中设置的标识符相对应。不确定问题是什么。我的 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 前面放置一个 _

关于ios - PFQueryTableViewController - CellForRowAtIndexPath 未被调用/不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42150381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com