简体   繁体   中英

xcode 7 not displaying data in parse table view in simulator, but works in device

I'm using Parse's table view class, I have my custom cell for the table view, everything worked fine in Xcode 6.3.2. I just updated my Xcode to 7 beta, because I want to run tests on my device without paying 100$ for developer account, anyways, the parse table view isn't displaying the data in table view: 表视图的屏幕截图

When actually when I try to print my query results to the console, I do get my results. Here's my code for the controller incharged for this view:

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
I just tried to run the app in my device, and the table is working like it should be, just the simulator isn't showing the data.

If data is loading on your device and not the simulator, it could be an issue of not simulating a location, which could prevent your query from pull results to populate the table view.

If this may be the case, you can simulate a location through the following options:
1) Xcode -> Debug -> Simulate Location (see screenshot below) by selecting one of the cities or adding a GPX file to your project.
2) Simulator -> Debug -> Location (see screenshot below).
3) You can also set your location via Maps on Simulator (see: http://apple.co/1JtnYIv ).

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM