diff --git a/DataSource/TableViewDataSource.swift b/DataSource/TableViewDataSource.swift
index 8f50a88..2fe487a 100644
--- a/DataSource/TableViewDataSource.swift
+++ b/DataSource/TableViewDataSource.swift
@@ -24,6 +24,9 @@ public class TableViewDataSource: NSObject {
/// Whether to show section titles
public var showSectionFooters: Bool?
+
+ /// Whether cells should be configured inside a UIView.performWithoutAnimation closure
+ public var configureWithoutAnimations: Bool = true
/// Optional closure which is called after a cell is dequeued, but before it's being configured (e.g. to "reset" a cell)
public var prepareCell: ((UITableViewCell, indexPath: NSIndexPath) -> Void)?
@@ -79,17 +82,31 @@ extension TableViewDataSource: UITableViewDataSource {
public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let row = dataSource.rowAtIndexPath(indexPath)
-
- if let configurator = configuratorForRowIdentifier(row.identifier) {
- let cell = tableView.dequeueReusableCellWithIdentifier(configurator.cellIdentifier, forIndexPath: indexPath)
- prepareCell?(cell, indexPath: indexPath)
- configurator.configureRow(row, cell: cell, indexPath: indexPath)
- return cell
+
+ let configure: () -> UITableViewCell = {
+ if let configurator = self.configuratorForRowIdentifier(row.identifier) {
+ let cell = tableView.dequeueReusableCellWithIdentifier(configurator.cellIdentifier, forIndexPath: indexPath)
+ self.prepareCell?(cell, indexPath: indexPath)
+ configurator.configureRow(row, cell: cell, indexPath: indexPath)
+ return cell
+ } else {
+ let cell = tableView.dequeueReusableCellWithIdentifier(row.identifier, forIndexPath: indexPath)
+ self.prepareCell?(cell, indexPath: indexPath)
+ return cell
+ }
+ }
+
+ var cell: UITableViewCell? = nil
+
+ if configureWithoutAnimations {
+ UIView.performWithoutAnimation {
+ cell = configure()
+ }
} else {
- let cell = tableView.dequeueReusableCellWithIdentifier(row.identifier, forIndexPath: indexPath)
- prepareCell?(cell, indexPath: indexPath)
- return cell
+ cell = configure()
}
+
+ return cell!
}
public func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
diff --git a/Example.xcodeproj/project.pbxproj b/Example.xcodeproj/project.pbxproj
index 41cf65b..8bf3efa 100644
--- a/Example.xcodeproj/project.pbxproj
+++ b/Example.xcodeproj/project.pbxproj
@@ -160,9 +160,9 @@
395D14A51B90612D00658680 /* DataSource */ = {
isa = PBXGroup;
children = (
- 39D82E581C04AC2C002A7B1B /* Extensions */,
395D14A61B90612D00658680 /* DataSource.h */,
39D82E491C049ABE002A7B1B /* DataSource.swift */,
+ 39D82E581C04AC2C002A7B1B /* Extensions */,
395D14A81B90612D00658680 /* Info.plist */,
3949A38E1C0706A200715B7F /* TableViewCellConfigurator.swift */,
39D82E4D1C049C34002A7B1B /* TableViewDataSource.swift */,
diff --git a/Example/Info.plist b/Example/Info.plist
index c2e40b8..0a890d0 100644
--- a/Example/Info.plist
+++ b/Example/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.1
+ 1.2
CFBundleSignature
????
CFBundleVersion
- 5
+ 6
LSRequiresIPhoneOS
UILaunchStoryboardName