From 743885613403f7747f73ac043d1130ba18d850a7 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 13:02:17 +0300
Subject: [PATCH 01/11] set estimatedHeight and defaultHeight as static
properties
---
.../Views/AutolayoutTableViewCell.swift | 8 +++----
.../Presentation/Views/NibTableViewCell.swift | 8 +++----
Sources/ConfigurableCell.swift | 24 ++++++++++++-------
Sources/TableRow.swift | 4 ++--
4 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/Demo/Classes/Presentation/Views/AutolayoutTableViewCell.swift b/Demo/Classes/Presentation/Views/AutolayoutTableViewCell.swift
index 6f5f7c4..ec505d6 100644
--- a/Demo/Classes/Presentation/Views/AutolayoutTableViewCell.swift
+++ b/Demo/Classes/Presentation/Views/AutolayoutTableViewCell.swift
@@ -19,13 +19,13 @@ class AutolayoutTableViewCell: UITableViewCell, ConfigurableCell {
@IBOutlet var titleLabel: UILabel!
@IBOutlet var subtitleLabel: UILabel!
+ static var estimatedHeight: CGFloat? {
+ return 500
+ }
+
func configure(with string: T) {
titleLabel.text = LoremIpsumTitle
subtitleLabel.text = LoremIpsumBody
}
-
- static func estimatedHeight() -> CGFloat? {
- return 500
- }
}
\ No newline at end of file
diff --git a/Demo/Classes/Presentation/Views/NibTableViewCell.swift b/Demo/Classes/Presentation/Views/NibTableViewCell.swift
index 74b4a27..d561314 100644
--- a/Demo/Classes/Presentation/Views/NibTableViewCell.swift
+++ b/Demo/Classes/Presentation/Views/NibTableViewCell.swift
@@ -13,11 +13,11 @@ class NibTableViewCell: UITableViewCell, ConfigurableCell {
@IBOutlet weak var titleLabel: UILabel!
+ static var defaultHeight: CGFloat? {
+ return 100
+ }
+
func configure(with number: Int) {
titleLabel.text = "\(number)"
}
-
- static func defaultHeight() -> CGFloat? {
- return 100
- }
}
\ No newline at end of file
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index 6c37e1f..021bad6 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -21,17 +21,18 @@
import UIKit
public protocol ReusableCell {
-
+
static func reusableIdentifier() -> String
static func nib() -> UINib?
}
public protocol ConfigurableCell: ReusableCell {
-
+
associatedtype T
-
- static func estimatedHeight() -> CGFloat?
- static func defaultHeight() -> CGFloat?
+
+ static var estimatedHeight: CGFloat? { get }
+ static var defaultHeight: CGFloat? { get }
+
func configure(with _: T)
}
@@ -48,11 +49,16 @@ public extension ReusableCell where Self: UITableViewCell {
public extension ConfigurableCell where Self: UITableViewCell {
- static func estimatedHeight() -> CGFloat? {
- return UITableViewAutomaticDimension
+ static var estimatedHeight: CGFloat? {
+ get {
+ return UITableViewAutomaticDimension
+ }
+
}
- static func defaultHeight() -> CGFloat? {
- return nil
+ static var defaultHeight: CGFloat? {
+ get {
+ return nil
+ }
}
}
\ No newline at end of file
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index d4f56e3..e0af219 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -59,11 +59,11 @@ public class TableRow
Date: Sat, 20 Aug 2016 13:03:31 +0300
Subject: [PATCH 02/11] fix tests
---
Tests/TableKitTests.swift | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Tests/TableKitTests.swift b/Tests/TableKitTests.swift
index d9df217..facffd3 100644
--- a/Tests/TableKitTests.swift
+++ b/Tests/TableKitTests.swift
@@ -42,21 +42,21 @@ struct TestTableViewCellOptions {
static let CellAction: String = "CellAction"
static let CellActionUserInfoKey: String = "CellActionUserInfoKey"
static let CellActionUserInfoValue: String = "CellActionUserInfoValue"
- static let EstimatedHeight: Float = 255
+ static let EstimatedHeight: CGFloat = 255
}
class TestTableViewCell: UITableViewCell, ConfigurableCell {
typealias T = TestData
+ static var estimatedHeight: CGFloat? {
+ return TestTableViewCellOptions.EstimatedHeight
+ }
+
static func reusableIdentifier() -> String {
return TestTableViewCellOptions.ReusableIdentifier
}
- static func estimatedHeight() -> Float {
- return TestTableViewCellOptions.EstimatedHeight
- }
-
func configure(with item: T) {
textLabel?.text = item.title
}
From ab6e88ad65ef040cc9b07651dc8c654ef8a6762a Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 13:19:35 +0300
Subject: [PATCH 03/11] add examples to readme
---
README.md | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index f740cc1..ba40144 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
@@ -17,7 +17,7 @@ It hides a complexity of `UITableViewDataSource` and `UITableViewDelegate` metho
- [x] Type-safe generic cells
- [x] Functional programming style friendly
- [x] The easiest way to map your models or view models to cells
-- [x] Automatic cell registration
+- [x] Automatic cell registration*
- [x] Correctly handles autolayout cells with multiline labels
- [x] Chainable cell actions (select/deselect etc.)
- [x] Support cells created from code, xib, or storyboard
@@ -36,7 +36,7 @@ Create your rows:
```swift
let row1 = TableRow(item: "1")
let row2 = TableRow(item: 2)
-let row3 = TableRow(item: 3.0)
+let row3 = TableRow(item: User(name: "John Doe", rating: 5))
```
Put rows into section:
```swift
@@ -47,19 +47,27 @@ And setup your table:
let tableDirector = TableDirector(tableView: tableView)
tableDirector += section
```
-Done. Your table is ready. You may want to look at your cell. It has to conform to `ConfigurableCell` protocol:
+Done. Your table is ready. Your cells have to conform to `ConfigurableCell` protocol:
```swift
class StringTableViewCell: UITableViewCell, ConfigurableCell {
- typealias T = String
+ func configure(with string: String) {
+
+ textLabel?.text = string
+ }
+}
- func configure(string: T, isPrototype: Bool) {
- titleLabel.text = string
+class UserTableViewCell: UITableViewCell, ConfigurableCell {
+
+ static var estimatedHeight: CGFloat? {
+ return 100
}
- static func estimatedHeight() -> CGFloat {
- return 44
- }
+ func configure(with user: User) {
+
+ textLabel?.text = user.name
+ detailTextLabel?.text = "Rating: \(user.rating)"
+ }
}
```
You could have as many rows and sections as you need.
@@ -74,7 +82,7 @@ let action = TableRowAction(.click) { (data) in
// data.cell - StringTableViewCell?
// data.item - String
- // data.path - NSIndexPath
+ // data.indexPath - NSIndexPath
}
let row = TableRow(item: "some", actions: [action])
@@ -82,12 +90,12 @@ let row = TableRow(item: "some", actions: [action])
Or, using nice chaining approach:
```swift
let row = TableRow(item: "some")
- .action(TableRowAction(.click) { (data) in
+ .action(.click) { (data) in
- })
- .action(TableRowAction(.shouldHighlight) { (data) -> Bool in
+ }
+ .action(.shouldHighlight) { (data) -> Bool in
return false
- })
+ }
```
You could find all available actions [here](Sources/TableRowAction.swift).
From b8084efc089b45d3f67d04d138e8d8efbbd6ce53 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 13:28:38 +0300
Subject: [PATCH 04/11] bump readme
---
README.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index ba40144..c4399fb 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
TableKit is a super lightweight yet powerful generic library that allows you to build complex table views in a declarative type-safe manner.
It hides a complexity of `UITableViewDataSource` and `UITableViewDelegate` methods behind the scene, so your code will be look clean, easy to read and nice to maintain.
-## Features
+# Features
- [x] Type-safe generic cells
- [x] Functional programming style friendly
@@ -26,11 +26,11 @@ It hides a complexity of `UITableViewDataSource` and `UITableViewDelegate` metho
- [x] No need to subclass
- [x] Extensibility
-## Getting Started
+# Getting Started
An [example app](Demo) is included demonstrating TableKit's functionality.
-#### Basic usage
+## Basic usage
Create your rows:
```swift
@@ -72,7 +72,7 @@ class UserTableViewCell: UITableViewCell, ConfigurableCell {
```
You could have as many rows and sections as you need.
-#### Row actions
+## Row actions
It nice to have some actions that related to your cells:
```swift
@@ -99,9 +99,9 @@ let row = TableRow(item: "some")
```
You could find all available actions [here](Sources/TableRowAction.swift).
-## Advanced
+# Advanced
-#### Cell height calculating strategy
+## Cell height calculating strategy
By default TableKit relies on self-sizing cells. In that case you have to provide an estimated height for your cells:
```swift
class StringTableViewCell: UITableViewCell, ConfigurableCell {
@@ -149,24 +149,24 @@ tableDirector += rows
```
Done, your table is ready. It's just awesome!
-## Installation
+# Installation
-#### CocoaPods
+## CocoaPods
To integrate TableKit into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
pod 'TableKit'
```
-#### Carthage
+## Carthage
Add the line `github "maxsokolov/tablekit"` to your `Cartfile`.
-#### Manual
+## Manual
Clone the repo and drag files from `Sources` folder into your Xcode project.
-## Requirements
+# Requirements
- iOS 8.0+
- Xcode 7.0+
-## License
+# License
TableKit is available under the MIT license. See LICENSE for details.
\ No newline at end of file
From a9c5d997cbc68399da0d8c8804f1429dcd6e5730 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 14:03:30 +0300
Subject: [PATCH 05/11] bump readme
---
README.md | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index c4399fb..274074c 100644
--- a/README.md
+++ b/README.md
@@ -138,16 +138,34 @@ class ImageTableViewCell: UITableViewCell, ConfigurableCell {
```
First of all you have to set `preferredMaxLayoutWidth` for all your multiline labels. And check if a configuring cell is a prototype cell. If it is, you don't have to do any additional work that not actually affect cell's height. For example you don't have to load remote image for a prototype cell.
-#### Functional programming
+## Functional programming
It's never been so easy to deal with table views.
```swift
let users = /* some users array */
-let rows: [Row] = users.filter({ $0.state == .active }).map({ TableRow(item: $0.username) })
+ let click = TableRowAction(.click) {
+
+ }
+
+let rows: [Row] = users.filter({ $0.state == .active }).map({ TableRow(item: $0.name, actions: [click]) })
tableDirector += rows
```
-Done, your table is ready. It's just awesome!
+Done, your table is ready.
+## Automatic cell registration
+
+TableKit can register your cells in table view automatically. In case if your reusable cell id mathces cell's xib name:
+
+```ruby
+MyTableViewCell.swift
+MyTableViewCell.xib
+
+```
+But you can turn off this behaviour:
+```swift
+let tableDirector = TableDirector(tableView: tableView, shouldUseAutomaticCellRegistration: false)
+```
+and register your cell manually.
# Installation
From d42757fb685b917b6035aec3e66e6776e86fcaa7 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 14:20:29 +0300
Subject: [PATCH 06/11] reuseIdentifier improvements
---
Sources/ConfigurableCell.swift | 27 +++++++++------------------
Sources/HeightStrategy.swift | 2 +-
Sources/TableCellManager.swift | 16 ++++++++--------
Sources/TableDirector.swift | 4 ++--
Sources/TableRow.swift | 6 +++---
Tests/TableKitTests.swift | 2 +-
6 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index 021bad6..18035ff 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -20,35 +20,26 @@
import UIKit
-public protocol ReusableCell {
-
- static func reusableIdentifier() -> String
- static func nib() -> UINib?
-}
-
-public protocol ConfigurableCell: ReusableCell {
+public protocol ConfigurableCell {
associatedtype T
+ static var reuseIdentifier: String { get }
static var estimatedHeight: CGFloat? { get }
static var defaultHeight: CGFloat? { get }
func configure(with _: T)
}
-public extension ReusableCell where Self: UITableViewCell {
-
- static func reusableIdentifier() -> String {
- return String(self)
- }
-
- static func nib() -> UINib? {
- return nil
- }
-}
-
public extension ConfigurableCell where Self: UITableViewCell {
+ static var reuseIdentifier: String {
+ get {
+ return String(self)
+ }
+
+ }
+
static var estimatedHeight: CGFloat? {
get {
return UITableViewAutomaticDimension
diff --git a/Sources/HeightStrategy.swift b/Sources/HeightStrategy.swift
index 7723bdd..66eec6f 100644
--- a/Sources/HeightStrategy.swift
+++ b/Sources/HeightStrategy.swift
@@ -49,7 +49,7 @@ public class PrototypeHeightStrategy: CellHeightCalculatable {
return height
}
- guard let cell = tableView.dequeueReusableCellWithIdentifier(row.reusableIdentifier) else { return 0 }
+ guard let cell = tableView.dequeueReusableCellWithIdentifier(row.reuseIdentifier) else { return 0 }
cell.bounds = CGRectMake(0, 0, tableView.bounds.size.width, cell.bounds.height)
diff --git a/Sources/TableCellManager.swift b/Sources/TableCellManager.swift
index 5cc29e8..e4b8c9a 100644
--- a/Sources/TableCellManager.swift
+++ b/Sources/TableCellManager.swift
@@ -29,16 +29,16 @@ public class TableCellManager {
self.tableView = tableView
}
- public func register(cellType cellType: AnyClass, forReusableCellIdentifier reusableIdentifier: String) {
+ public func register(cellType cellType: AnyClass, forCellReuseIdentifier reuseIdentifier: String) {
- if registeredIds.contains(reusableIdentifier) {
+ if registeredIds.contains(reuseIdentifier) {
return
}
// check if cell is already registered, probably cell has been registered by storyboard
- if tableView?.dequeueReusableCellWithIdentifier(reusableIdentifier) != nil {
+ if tableView?.dequeueReusableCellWithIdentifier(reuseIdentifier) != nil {
- registeredIds.insert(reusableIdentifier)
+ registeredIds.insert(reuseIdentifier)
return
}
@@ -46,13 +46,13 @@ public class TableCellManager {
// we hope that cell's xib file has name that equals to cell's class name
// in that case we could register nib
- if let _ = bundle.pathForResource(reusableIdentifier, ofType: "nib") {
- tableView?.registerNib(UINib(nibName: reusableIdentifier, bundle: bundle), forCellReuseIdentifier: reusableIdentifier)
+ if let _ = bundle.pathForResource(reuseIdentifier, ofType: "nib") {
+ tableView?.registerNib(UINib(nibName: reuseIdentifier, bundle: bundle), forCellReuseIdentifier: reuseIdentifier)
// otherwise, register cell class
} else {
- tableView?.registerClass(cellType, forCellReuseIdentifier: reusableIdentifier)
+ tableView?.registerClass(cellType, forCellReuseIdentifier: reuseIdentifier)
}
- registeredIds.insert(reusableIdentifier)
+ registeredIds.insert(reuseIdentifier)
}
}
\ No newline at end of file
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index 6794b24..ff6fd3f 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -123,9 +123,9 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
let row = sections[indexPath.section].items[indexPath.row]
- cellManager?.register(cellType: row.cellType, forReusableCellIdentifier: row.reusableIdentifier)
+ cellManager?.register(cellType: row.cellType, forCellReuseIdentifier: row.reuseIdentifier)
- let cell = tableView.dequeueReusableCellWithIdentifier(row.reusableIdentifier, forIndexPath: indexPath)
+ let cell = tableView.dequeueReusableCellWithIdentifier(row.reuseIdentifier, forIndexPath: indexPath)
if cell.frame.size.width != tableView.frame.size.width {
cell.frame = CGRectMake(0, 0, tableView.frame.size.width, cell.frame.size.height)
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index e0af219..b3cd9d1 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -38,7 +38,7 @@ public protocol RowHashable {
public protocol Row: RowConfigurable, RowActionable, RowHashable {
- var reusableIdentifier: String { get }
+ var reuseIdentifier: String { get }
var cellType: AnyClass { get }
var estimatedHeight: CGFloat? { get }
@@ -54,8 +54,8 @@ public class TableRow String {
+ static var reuseIdentifier: String {
return TestTableViewCellOptions.ReusableIdentifier
}
From 7a732cb7c3eb09a43bc841d00172073f18b246f5 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 16:25:08 +0300
Subject: [PATCH 07/11] bump readme
---
README.md | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 274074c..b896979 100644
--- a/README.md
+++ b/README.md
@@ -63,6 +63,12 @@ class UserTableViewCell: UITableViewCell, ConfigurableCell {
return 100
}
+ // is not required to be implemented
+ // by default reuse id is equal to class name
+ static var reuseIdentifier: String {
+ return "my id"
+ }
+
func configure(with user: User) {
textLabel?.text = user.name
@@ -121,11 +127,9 @@ It does all dirty work with prototypes for you [behind the scene](Sources/Height
```swift
class ImageTableViewCell: UITableViewCell, ConfigurableCell {
- func configure(url: NSURL, isPrototype: Bool) {
+ func configure(with url: NSURL, isPrototype: Bool) {
- if !isPrototype {
- loadImageAsync(url: url, imageView: imageView)
- }
+ loadImageAsync(url: url, imageView: imageView)
}
override func layoutSubviews() {
@@ -136,16 +140,16 @@ class ImageTableViewCell: UITableViewCell, ConfigurableCell {
}
}
```
-First of all you have to set `preferredMaxLayoutWidth` for all your multiline labels. And check if a configuring cell is a prototype cell. If it is, you don't have to do any additional work that not actually affect cell's height. For example you don't have to load remote image for a prototype cell.
+You have to additionally set `preferredMaxLayoutWidth` for all your multiline labels.
## Functional programming
It's never been so easy to deal with table views.
```swift
let users = /* some users array */
- let click = TableRowAction(.click) {
+let click = TableRowAction(.click) {
- }
+}
let rows: [Row] = users.filter({ $0.state == .active }).map({ TableRow(item: $0.name, actions: [click]) })
@@ -161,7 +165,7 @@ MyTableViewCell.swift
MyTableViewCell.xib
```
-But you can turn off this behaviour:
+You can also turn off this behaviour:
```swift
let tableDirector = TableDirector(tableView: tableView, shouldUseAutomaticCellRegistration: false)
```
From a9a2496831eae343950b9d35be846fe2659f4e30 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 16:30:39 +0300
Subject: [PATCH 08/11] make TableCellManager internal
---
Sources/TableCellManager.swift | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Sources/TableCellManager.swift b/Sources/TableCellManager.swift
index e4b8c9a..891266e 100644
--- a/Sources/TableCellManager.swift
+++ b/Sources/TableCellManager.swift
@@ -20,16 +20,16 @@
import UIKit
-public class TableCellManager {
+class TableCellManager {
private var registeredIds = Set()
private weak var tableView: UITableView?
- public init(tableView: UITableView?) {
+ init(tableView: UITableView?) {
self.tableView = tableView
}
- public func register(cellType cellType: AnyClass, forCellReuseIdentifier reuseIdentifier: String) {
+ func register(cellType cellType: AnyClass, forCellReuseIdentifier reuseIdentifier: String) {
if registeredIds.contains(reuseIdentifier) {
return
From 4dd21a7d2e41ad0ac95a6d77649d372bedc49858 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 16:41:10 +0300
Subject: [PATCH 09/11] bump readme
---
README.md | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index b896979..396d01d 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,8 @@ let section = TableSection(rows: [row1, row2, row3])
```
And setup your table:
```swift
+import TableKit
+
let tableDirector = TableDirector(tableView: tableView)
tableDirector += section
```
@@ -64,7 +66,7 @@ class UserTableViewCell: UITableViewCell, ConfigurableCell {
}
// is not required to be implemented
- // by default reuse id is equal to class name
+ // by default reuse id is equal to cell's class name
static var reuseIdentifier: String {
return "my id"
}
@@ -105,6 +107,30 @@ let row = TableRow(item: "some")
```
You could find all available actions [here](Sources/TableRowAction.swift).
+## Custom row actions
+
+You are able to define your own actions:
+```swift
+struct MyActions {
+
+ static let ButtonClicked = "ButtonClicked"
+}
+
+class MyTableViewCell: UITableViewCell, ConfigurableCell {
+
+ @IBAction func lol(sender: UIButton) {
+
+ TableCellAction(key: MyActions.ButtonClicked, sender: self).invoke()
+ }
+}
+```
+And handle them accordingly:
+```swift
+let myAction = TableRowAction(.custom(MyActions.ButtonClicked)) { (data) in
+
+}
+```
+
# Advanced
## Cell height calculating strategy
@@ -127,7 +153,7 @@ It does all dirty work with prototypes for you [behind the scene](Sources/Height
```swift
class ImageTableViewCell: UITableViewCell, ConfigurableCell {
- func configure(with url: NSURL, isPrototype: Bool) {
+ func configure(with url: NSURL) {
loadImageAsync(url: url, imageView: imageView)
}
From d3773efbcc7824a7c48c80f22653053a6ed5d53d Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 16:44:58 +0300
Subject: [PATCH 10/11] update readme
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 396d01d..bfa444a 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,8 @@ An [example app](Demo) is included demonstrating TableKit's functionality.
Create your rows:
```swift
+import TableKit
+
let row1 = TableRow(item: "1")
let row2 = TableRow(item: 2)
let row3 = TableRow(item: User(name: "John Doe", rating: 5))
@@ -44,8 +46,6 @@ let section = TableSection(rows: [row1, row2, row3])
```
And setup your table:
```swift
-import TableKit
-
let tableDirector = TableDirector(tableView: tableView)
tableDirector += section
```
@@ -118,7 +118,7 @@ struct MyActions {
class MyTableViewCell: UITableViewCell, ConfigurableCell {
- @IBAction func lol(sender: UIButton) {
+ @IBAction func myButtonClicked(sender: UIButton) {
TableCellAction(key: MyActions.ButtonClicked, sender: self).invoke()
}
@@ -126,7 +126,7 @@ class MyTableViewCell: UITableViewCell, ConfigurableCell {
```
And handle them accordingly:
```swift
-let myAction = TableRowAction(.custom(MyActions.ButtonClicked)) { (data) in
+let myAction = TableRowAction(.custom(MyActions.ButtonClicked)) { (data) in
}
```
@@ -145,7 +145,7 @@ class StringTableViewCell: UITableViewCell, ConfigurableCell {
}
}
```
-It's enough for most cases. But you may be not happy with this. So you could use a prototype cell to calculate cell's heights. To enable this feature simply use this property:
+It's enough for most cases. But you may be not happy with this. So you could use a prototype cell to calculate cells heights. To enable this feature simply use this property:
```swift
tableDirector.shouldUsePrototypeCellHeightCalculation = true
```
From 520f1f91f09574599c72ff4806848a96412733e2 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sat, 20 Aug 2016 16:47:14 +0300
Subject: [PATCH 11/11] update readme
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index bfa444a..c3adbf6 100644
--- a/README.md
+++ b/README.md
@@ -140,8 +140,8 @@ class StringTableViewCell: UITableViewCell, ConfigurableCell {
// ...
- static func estimatedHeight() -> CGFloat {
- return 44
+ static var estimatedHeight: CGFloat? {
+ return 255
}
}
```