1

In my PFQueryTableViewController, the custom PFTableViewCell's dont have any separators and i don't know why.

enter image description here

I didn't find anything when googeling.

What am I doing wrong?

    class CategoryTableViewController: PFQueryTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
            }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.loadObjects()
    }


    // 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 = "Category"

        self.pullToRefreshEnabled = true
        self.paginationEnabled = false


    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // Mark - PFQueryTableViewController

    override func queryForTable() -> PFQuery {

        var query = PFQuery(className: self.parseClassName!)

        return query
    }

    // Mark: UITableViewDataSource

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> (PFTableViewCell!) {
        var cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! PFTableViewCell


        cell.accessoryType = UITableViewCellAccessoryType.Checkmark
        cell.textLabel?.text = object["name"] as? String

        return cell
    }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Daniel Storch
  • 979
  • 3
  • 10
  • 25

3 Answers3

6

Override the objectsDidLoad: method with this and the UI should go back to normal:

- (void)objectsDidLoad:(NSError *)error {
    [super objectsDidLoad:error];
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
}
Alex
  • 7,432
  • 20
  • 75
  • 118
2

So this is quite old, but when I removed the self.loadObjects() from my viewWillAppear method the tableview separators came back. Not sure if this is a parse bug or not but I thought I would just point that out.

Logan Garland
  • 242
  • 4
  • 12
1

I had the same problem. Didn't find out what causes it yet, but here's a hack that I did which might help you too. In cellForRowAtIndexPath add this:

var separator = CALayer()
separator.backgroundColor = UIColor.lightGrayColor().colorWithAlphaComponent(0.2).CGColor
separator.frame = CGRectMake(0, 100, self.view.frame.size.width, 1);
cell.layer.addSublayer(separator)

This will add a 1px layer that looks like a separator. You can play with the color, width of it.

Andu Morie
  • 26
  • 1
  • Thanks, it works. Had to change the "100" for the hight of my cell. But you don't know why the separators don't show when using PFQueryTableViewController and PFTableViewCell? – Daniel Storch May 20 '15 at 16:38
  • No, as I said, I didn't manage to find out the cause of them not showing yet, unfortunately. I'm glad my little hack worked for you too! – Andu Morie May 22 '15 at 21:40