[英]xcode 7 not displaying data in parse table view in simulator, but works in device
我正在使用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;
}
}
UPDATE
我只是试图在我的设备中运行应用程序,并且表格正常运行,只是模拟器没有显示数据。
如果数据正在您的设备而不是模拟器上加载,则可能是不模拟位置的问题,这可能会阻止您的查询从拉取结果填充表格视图。
如果是这种情况,您可以通过以下选项模拟位置:
1)Xcode - > Debug - > Simulate Location(见下面的截图)选择一个城市或将GPX文件添加到项目中。
2)模拟器 - >调试 - >位置(见下面的截图)。
3)您还可以通过模拟器上的地图设置您的位置(请参阅: http : //apple.co/1JtnYIv )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.