fix cell action
This commit is contained in:
parent
1e4f76e04f
commit
310cec9c12
|
|
@ -20,12 +20,10 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
struct TabletNotifications {
|
||||
static let CellAction = "TabletNotificationsCellAction"
|
||||
struct TableKitNotifications {
|
||||
static let CellAction = "TableKitNotificationsCellAction"
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A custom action that you can trigger from your cell.
|
||||
You can eacily catch actions using a chaining manner with your row builder.
|
||||
|
|
@ -49,6 +47,6 @@ public class TableCellAction {
|
|||
}
|
||||
|
||||
public func invoke() {
|
||||
NSNotificationCenter.defaultCenter().postNotificationName(TabletNotifications.CellAction, object: self, userInfo: userInfo)
|
||||
NSNotificationCenter.defaultCenter().postNotificationName(TableKitNotifications.CellAction, object: self, userInfo: userInfo)
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
self.tableView?.delegate = self
|
||||
self.tableView?.dataSource = self
|
||||
|
||||
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(didReceiveAction), name: TabletNotifications.CellAction, object: nil)
|
||||
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(didReceiveAction), name: TableKitNotifications.CellAction, object: nil)
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
|
@ -69,12 +69,9 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
}
|
||||
|
||||
func didReceiveAction(notification: NSNotification) {
|
||||
|
||||
//if let action = notification.object as? Action, indexPath = tableView?.indexPathForCell(action.cell) {
|
||||
|
||||
//let builder = builderAtIndexPath(indexPath)
|
||||
//builder.0.invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath, itemIndex: builder.1, userInfo: notification.userInfo)
|
||||
//}
|
||||
|
||||
guard let action = notification.object as? TableCellAction, indexPath = tableView?.indexPathForCell(action.cell) else { return }
|
||||
invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath)
|
||||
}
|
||||
|
||||
// MARK: - Height
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
DA9EA7751D0B68460021F650 /* TableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76C1D0B68460021F650 /* TableRow.swift */; };
|
||||
DA9EA7761D0B68460021F650 /* TableRowAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76D1D0B68460021F650 /* TableRowAction.swift */; };
|
||||
DA9EA7781D0B68460021F650 /* TableSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76F1D0B68460021F650 /* TableSection.swift */; };
|
||||
DA9EA7791D0B68460021F650 /* Tablet.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7701D0B68460021F650 /* Tablet.swift */; };
|
||||
DA9EA7791D0B68460021F650 /* TableCellAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7701D0B68460021F650 /* TableCellAction.swift */; };
|
||||
DA9EA7801D0B689C0021F650 /* TableKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DA9EA77E1D0B689C0021F650 /* TableKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
DA9EA76C1D0B68460021F650 /* TableRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRow.swift; sourceTree = "<group>"; };
|
||||
DA9EA76D1D0B68460021F650 /* TableRowAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowAction.swift; sourceTree = "<group>"; };
|
||||
DA9EA76F1D0B68460021F650 /* TableSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableSection.swift; sourceTree = "<group>"; };
|
||||
DA9EA7701D0B68460021F650 /* Tablet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tablet.swift; sourceTree = "<group>"; };
|
||||
DA9EA7701D0B68460021F650 /* TableCellAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCellAction.swift; sourceTree = "<group>"; };
|
||||
DA9EA77D1D0B689C0021F650 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
DA9EA77E1D0B689C0021F650 /* TableKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableKit.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
|
@ -67,10 +67,10 @@
|
|||
DA9EA76F1D0B68460021F650 /* TableSection.swift */,
|
||||
DA9EA76C1D0B68460021F650 /* TableRow.swift */,
|
||||
DA9EA76D1D0B68460021F650 /* TableRowAction.swift */,
|
||||
DA9EA7701D0B68460021F650 /* TableCellAction.swift */,
|
||||
DA9EA7681D0B68460021F650 /* ConfigurableCell.swift */,
|
||||
DA9EA7691D0B68460021F650 /* HeightStrategy.swift */,
|
||||
DA9EA76A1D0B68460021F650 /* Operators.swift */,
|
||||
DA9EA7701D0B68460021F650 /* Tablet.swift */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -168,7 +168,7 @@
|
|||
DA9EA7751D0B68460021F650 /* TableRow.swift in Sources */,
|
||||
DA9EA7761D0B68460021F650 /* TableRowAction.swift in Sources */,
|
||||
DA9EA7741D0B68460021F650 /* TableDirector.swift in Sources */,
|
||||
DA9EA7791D0B68460021F650 /* Tablet.swift in Sources */,
|
||||
DA9EA7791D0B68460021F650 /* TableCellAction.swift in Sources */,
|
||||
DA9EA7731D0B68460021F650 /* Operators.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
|||
|
|
@ -22,12 +22,15 @@ class StoryboardImageTableViewCell: UITableViewCell, ConfigurableCell {
|
|||
titleLabel.text = string
|
||||
subtitleLabel.text = "Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.1"
|
||||
}
|
||||
|
||||
static func estimatedHeight() -> CGFloat {
|
||||
return 500
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
contentView.layoutIfNeeded()
|
||||
|
||||
subtitleLabel.preferredMaxLayoutWidth = subtitleLabel.bounds.size.width
|
||||
//contentView.layoutIfNeeded()
|
||||
//subtitleLabel.preferredMaxLayoutWidth = subtitleLabel.bounds.size.width
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue