diff --git a/Tablet/TableDirector.swift b/Tablet/TableDirector.swift index 8f2f74e..b8bb781 100644 --- a/Tablet/TableDirector.swift +++ b/Tablet/TableDirector.swift @@ -146,8 +146,19 @@ extension TableDirector { } extension TableDirector { - + // MARK: UITableViewDelegate - actions + + public func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + + return builderAtIndexPath(indexPath).0.estimatedRowHeight + } + + public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + + + return triggerAction(.height, cell: nil, indexPath: indexPath) as? CGFloat ?? UITableViewAutomaticDimension + } public func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { @@ -174,15 +185,4 @@ extension TableDirector { return triggerAction(.shouldHighlight, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) as? Bool ?? true } - - public func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { - - return 300 - } - - public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { - - print(indexPath) - return triggerAction(.height, cell: nil, indexPath: indexPath) as? CGFloat ?? UITableViewAutomaticDimension - } } \ No newline at end of file diff --git a/Tablet/TableRowBuilder.swift b/Tablet/TableRowBuilder.swift index c3cf2fd..a09de24 100644 --- a/Tablet/TableRowBuilder.swift +++ b/Tablet/TableRowBuilder.swift @@ -49,21 +49,21 @@ public class TableRowBuilder : RowBuilder { private var items = [I]() public var reusableIdentifier: String - public var estimatedRowHeight: Float + public var estimatedRowHeight: CGFloat public var numberOfRows: Int { get { return items.count } } - public init(item: I, id: String, estimatedRowHeight: Float = 0) { + public init(item: I, id: String, estimatedRowHeight: CGFloat = UITableViewAutomaticDimension) { reusableIdentifier = id self.estimatedRowHeight = estimatedRowHeight items.append(item) } - public init(items: [I]? = nil, id: String, estimatedRowHeight: Float = 0) { + public init(items: [I]? = nil, id: String, estimatedRowHeight: CGFloat = UITableViewAutomaticDimension) { reusableIdentifier = id self.estimatedRowHeight = estimatedRowHeight @@ -121,11 +121,11 @@ public class TableRowBuilder : RowBuilder { */ public class TableConfigurableRowBuilder : TableRowBuilder { - public init(item: I, estimatedRowHeight: Float = 0) { + public init(item: I, estimatedRowHeight: CGFloat = UITableViewAutomaticDimension) { super.init(item: item, id: C.reusableIdentifier(), estimatedRowHeight: estimatedRowHeight) } - public init(items: [I]? = nil, estimatedRowHeight: Float = 0) { + public init(items: [I]? = nil, estimatedRowHeight: CGFloat = UITableViewAutomaticDimension) { super.init(items: items, id: C.reusableIdentifier(), estimatedRowHeight: estimatedRowHeight) } diff --git a/Tablet/Tablet.swift b/Tablet/Tablet.swift index 64cfafa..6ceeeaf 100644 --- a/Tablet/Tablet.swift +++ b/Tablet/Tablet.swift @@ -112,7 +112,7 @@ public protocol RowBuilder { var numberOfRows: Int { get } var reusableIdentifier: String { get } - var estimatedRowHeight: Float { get } + var estimatedRowHeight: CGFloat { get } func triggerAction(actionType: ActionType, cell: UITableViewCell?, indexPath: NSIndexPath, itemIndex: Int) -> AnyObject? } \ No newline at end of file diff --git a/TabletDemo/TabletDemo.xcodeproj/project.pbxproj b/TabletDemo/TabletDemo.xcodeproj/project.pbxproj index 3a5cbf8..f241c66 100644 --- a/TabletDemo/TabletDemo.xcodeproj/project.pbxproj +++ b/TabletDemo/TabletDemo.xcodeproj/project.pbxproj @@ -122,6 +122,7 @@ TargetAttributes = { DAB7EB261BEF787300D2AD5E = { CreatedOnToolsVersion = 7.0.1; + DevelopmentTeam = Z48R734SJX; }; }; }; @@ -279,11 +280,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = TabletDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablet.TabletDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Debug; }; @@ -291,11 +295,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = TabletDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablet.TabletDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Release; }; diff --git a/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate b/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate index 6c57e1d..61803cb 100644 Binary files a/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate and b/TabletDemo/TabletDemo.xcodeproj/project.xcworkspace/xcuserdata/maxsokolov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TabletDemo/TabletDemo/ViewController.swift b/TabletDemo/TabletDemo/ViewController.swift index 9b0aa9b..3638950 100644 --- a/TabletDemo/TabletDemo/ViewController.swift +++ b/TabletDemo/TabletDemo/ViewController.swift @@ -45,17 +45,12 @@ class ViewController: UIViewController { return nil } .action(.configure) { (data) -> Void in - + data.cell!.contentLabel.text = "With iOS 8, Apple has internalized much of the work that previously had to be implemented by you prior to iOS 8. In order to allow the self-sizing cell mechanism to work, you must first set the rowHeight property on the table view to the constant UITableViewAutomaticDimension. Then, you simply need to enable row height estimation by setting the table view's estimatedRowHeight property to a nonzero value, for example" - - //data.cell!.setNeedsUpdateConstraints() - //data.cell!.updateConstraintsIfNeeded() } - let sectionBuilder = TableSectionBuilder(headerTitle: "Tablet", footerTitle: "Deal with table view like a boss.", rowBuilders: [configurableRowBuilder]) + let sectionBuilder = TableSectionBuilder(headerTitle: "Tablet", footerTitle: "Deal with table view like a boss.", rowBuilders: [rowBuilder, configurableRowBuilder]) tableDirector.appendSection(sectionBuilder) } -} - -// вход со стороны кутузовского проспекта между домами 10 14 левее чайхоны, на охране сказать кодовое слово Магия - найти клуб лабиринт \ No newline at end of file +} \ No newline at end of file