From 2e8b3f3232afe49bde5f3be7174374a9609144e8 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Wed, 17 Aug 2016 12:02:00 +0300 Subject: [PATCH] implement custom cell height action --- Demo/Classes/Presentation/Controllers/MainController.swift | 3 --- .../Classes/Presentation/Controllers/NibCellsController.swift | 2 +- Sources/TableDirector.swift | 4 +++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Demo/Classes/Presentation/Controllers/MainController.swift b/Demo/Classes/Presentation/Controllers/MainController.swift index 251ab9e..5a286a1 100644 --- a/Demo/Classes/Presentation/Controllers/MainController.swift +++ b/Demo/Classes/Presentation/Controllers/MainController.swift @@ -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(item: "Autolayout cells", actions: [clickAction]), - TableRow(item: "Row builder cells", actions: [clickAction]), TableRow(item: "Nib cells", actions: [clickAction]) ] diff --git a/Demo/Classes/Presentation/Controllers/NibCellsController.swift b/Demo/Classes/Presentation/Controllers/NibCellsController.swift index 15a6cce..c6d69f5 100644 --- a/Demo/Classes/Presentation/Controllers/NibCellsController.swift +++ b/Demo/Classes/Presentation/Controllers/NibCellsController.swift @@ -26,7 +26,7 @@ class NibCellsController: UITableViewController { let shouldHighlightAction = TableRowAction(.shouldHighlight) { (_) -> Bool in return false } - + let rows: [Row] = numbers.map { TableRow(item: $0, actions: [shouldHighlightAction]) } tableDirector.append(rows: rows) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 2ad6581..710c77a 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -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