From 0c5f24a4910352f09d5042c9019010e97f8dea78 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Tue, 7 Jun 2016 02:15:37 +0300 Subject: [PATCH] fix --- Tablet/ConfigurableCell.swift | 10 +++++----- Tablet/HeightStrategy.swift | 8 +------- Tablet/TableRowBuilder.swift | 5 +++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Tablet/ConfigurableCell.swift b/Tablet/ConfigurableCell.swift index 6622122..2db62b5 100644 --- a/Tablet/ConfigurableCell.swift +++ b/Tablet/ConfigurableCell.swift @@ -30,7 +30,7 @@ public protocol ConfigurableCell { static func reusableIdentifier() -> String static func estimatedHeight() -> CGFloat - static func defaultHeight() -> Float? + static func defaultHeight() -> CGFloat? func configure(_: T) } @@ -40,11 +40,11 @@ public extension ConfigurableCell where Self: UITableViewCell { return String(self) } - static func defaultHeight() -> Float? { - return nil - } - static func estimatedHeight() -> CGFloat { return UITableViewAutomaticDimension } + + static func defaultHeight() -> CGFloat? { + return nil + } } \ No newline at end of file diff --git a/Tablet/HeightStrategy.swift b/Tablet/HeightStrategy.swift index 75f9516..c34bd40 100644 --- a/Tablet/HeightStrategy.swift +++ b/Tablet/HeightStrategy.swift @@ -21,12 +21,10 @@ import UIKit public protocol HeightStrategy { - + var tableView: UITableView? { get set } func height(item: Item, indexPath: NSIndexPath, cell: Cell.Type) -> CGFloat - - func estimatedHeight() -> CGFloat } public class PrototypeHeightStrategy: HeightStrategy { @@ -47,8 +45,4 @@ public class PrototypeHeightStrategy: HeightStrategy { return cell.contentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height + 1 } - - public func estimatedHeight() -> CGFloat { - return UITableViewAutomaticDimension - } } \ No newline at end of file diff --git a/Tablet/TableRowBuilder.swift b/Tablet/TableRowBuilder.swift index 0dabcfa..b5f2d53 100644 --- a/Tablet/TableRowBuilder.swift +++ b/Tablet/TableRowBuilder.swift @@ -33,7 +33,6 @@ public class TableRowBuilder]() private var items = [DataType]() - public func reusableIdentifier(_: Int) -> String { return CellType.reusableIdentifier() } @@ -41,6 +40,8 @@ public class TableRowBuilder CGFloat { - return heightStrategy?.height(item(index: index), indexPath: indexPath, cell: CellType.self) ?? 0 + return CellType.defaultHeight() ?? heightStrategy?.height(item(index: index), indexPath: indexPath, cell: CellType.self) ?? UITableViewAutomaticDimension } public func estimatedRowHeight(index: Int, indexPath: NSIndexPath) -> CGFloat {