2017-02-10 1 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 앞에 _을 배치하는 것입니다.

관련 문제