I have a UIViewController with table view which takes the data from Parse and it works well with auto sizing. While reading the documentation I saw that there is a controller named PFQueryTableViewController which comes whit pagination, pull to refresh and other cool features. But now the auto sizing doesn't work and every cell covers the next. Here's my code:
import UIKit
class WallParse: PFQueryTableViewController {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.parseClassName = "Post"
self.pullToRefreshEnabled = true
self.paginationEnabled = true
self.objectsPerPage = 3
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.estimatedRowHeight = 400
self.tableView.rowHeight = UITableViewAutomaticDimension
}
override init!(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
override func queryForTable() -> PFQuery {
var query = PFQuery (className: self.parseClassName)
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if (self.objects.count == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
query.orderByDescending("createdAt")
return query
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {
let cellIdentifier = "cell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as WallCell
// Configure the cell to show todo item with a priority at the bottom
cell.commentLabel.text = object["text"] as? String
return cell;
}
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
}