From 272d238a2a9858a9d51aade9b3ad5a2d6c5d2227 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 12 Jun 2016 17:01:44 +0300 Subject: [PATCH] fix willSelect --- TableKit/TableDirector.swift | 17 ++++++++++++----- .../Controllers/MainController.swift | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/TableKit/TableDirector.swift b/TableKit/TableDirector.swift index b4f3ccb..7ddb85b 100644 --- a/TableKit/TableDirector.swift +++ b/TableKit/TableDirector.swift @@ -64,6 +64,10 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate // MARK: - Internal - + func hasAction(action: TableRowActionType, atIndexPath indexPath: NSIndexPath) -> Bool { + return sections[indexPath.section].items[indexPath.row].hasAction(action) + } + func didReceiveAction(notification: NSNotification) { if let action = notification.object as? Action, indexPath = tableView?.indexPathForCell(action.cell) { @@ -160,11 +164,14 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate public func tableView(tableView: UITableView, shouldHighlightRowAtIndexPath indexPath: NSIndexPath) -> Bool { return invoke(action: .shouldHighlight, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? Bool ?? true } - - /*func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { - - return invokeAction(.willSelect, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? NSIndexPath - }*/ + + public func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { + + if hasAction(.willSelect, atIndexPath: indexPath) { + return invoke(action: .willSelect, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? NSIndexPath + } + return indexPath + } // MARK: - Sections manipulation - diff --git a/TableKitDemo/Classes/Presentation/Controllers/MainController.swift b/TableKitDemo/Classes/Presentation/Controllers/MainController.swift index 098588c..91f679e 100644 --- a/TableKitDemo/Classes/Presentation/Controllers/MainController.swift +++ b/TableKitDemo/Classes/Presentation/Controllers/MainController.swift @@ -64,7 +64,7 @@ class MainController: UIViewController { tableDirector += [section] - tableDirector.append(section: section) + //tableDirector.append(section: section)