implement custom cell height action

This commit is contained in:
Max Sokolov 2016-08-17 12:02:00 +03:00
parent da51e2b7e9
commit 2e8b3f3232
3 changed files with 4 additions and 5 deletions

View File

@ -30,8 +30,6 @@ class MainController: UIViewController {
case 0:
self?.performSegueWithIdentifier("autolayoutcells", sender: nil)
case 1:
self?.performSegueWithIdentifier("rowbuildercells", sender: nil)
case 2:
self?.performSegueWithIdentifier("nibcells", sender: nil)
default:
break
@ -41,7 +39,6 @@ class MainController: UIViewController {
let rows: [Row] = [
TableRow<String, ConfigurableTableViewCell>(item: "Autolayout cells", actions: [clickAction]),
TableRow<String, ConfigurableTableViewCell>(item: "Row builder cells", actions: [clickAction]),
TableRow<String, ConfigurableTableViewCell>(item: "Nib cells", actions: [clickAction])
]

View File

@ -26,7 +26,7 @@ class NibCellsController: UITableViewController {
let shouldHighlightAction = TableRowAction<Int, NibTableViewCell>(.shouldHighlight) { (_) -> Bool in
return false
}
let rows: [Row] = numbers.map { TableRow<Int, NibTableViewCell>(item: $0, actions: [shouldHighlightAction]) }
tableDirector.append(rows: rows)

View File

@ -119,7 +119,9 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let row = sections[indexPath.section].items[indexPath.row]
return heightStrategy?.height(row, path: indexPath) ?? row.defaultHeight
let rowHeight = invoke(action: .height, cell: nil, indexPath: indexPath) as? CGFloat
return rowHeight ?? heightStrategy?.height(row, path: indexPath) ?? row.defaultHeight
}
// MARK: UITableViewDataSource - configuration