我正在使用 Parse 的表格视图类,我有表格视图的自定义单元格,在 Xcode 6.3.2 中一切正常。我刚刚将我的 Xcode 更新到 7 beta,因为我想在我的设备上运行测试而不为开发者帐户支付 100 美元,无论如何,解析表视图不会在表视图中显示数据:
实际上,当我尝试将查询结果打印到控制台时,我确实得到了结果。这是我为此视图负责的控制器的代码:
import UIKit
import Parse
import ParseUI
class MeetsTableViewController: PFQueryTableViewController {
// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Configure the PFQueryTableView
self.parseClassName = "Meets";
self.pullToRefreshEnabled = true;
self.textKey="city";
self.paginationEnabled = false;
}
// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery {
let query = PFQuery(className: "Meets");
query.orderByDescending("numberOfComming");
return query;
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("MyCell") as! CarTableViewCell!;
if cell == nil {
cell = CarTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "MyCell");
}
if let cityName = object?["city"] as? String{
cell?.meetName?.text = "מפגש ב\(cityName)";
}
if let address = object?["address"] as? String{
cell?.meetAddress?.text = address;
}
if let date = object?["date"] as? String{
cell?.meetDate?.text = date;
}
if let time = object?["time"] as? String{
cell?.meetTime?.text = time;
}
if let people = object?["numberOfComming"] as? Int{
cell?.peopleAttending?.text = "\(people)";
}
print(object); // console is printing query results successfully
if let thumbnail = object?["meetImg"] as? PFFile {
thumbnail.getDataInBackgroundWithBlock{
(imageData, error) -> Void in
if error == nil {
let image = UIImage(data: imageData!)
cell.meetImage.image = image
}}
}
return cell;
}
}
更新
我只是尝试在我的设备中运行该应用程序,并且该表正常工作,只是模拟器没有显示数据。