PFQueryTableView Custom cell Separator not showing

319 views Asked by At

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
    }
}
3

There are 3 answers

2
Andu Morie On BEST ANSWER

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.

0
Logan Garland On

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.

0
Alex On

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];
}