2017-02-10 10 views
0

私はParseサーバーからユーザーにデータを表示するためにPFQueryTableViewControllerを実装しようとしています。何らかの理由で、私のカスタムプロトタイプセルはまったく使用されていません。むしろ、テーブルは単に表示しているだけです(xは数字を表します)。私はすべてのアウトレットが正しく接続されていることを確認し、再利用識別子はストーリーボードに設定した識別子に対応していることを確認しました。問題の内容がわからない私のPFQueryTableViewControllerとPFTableViewCellのコードは以下の通りです。誰かが私を助けることができれば感謝します。PFQueryTableViewController - CellForRowAtIndexPathが呼び出されていない/動作していない

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

うわーは、ちょうどそれを考え出しました。私がしなければならなかったのは、cellForRowAtIndexPath関数の最初のtableViewの前に_を置くことでした。

関連する問題