├── .gitignore ├── DynamicCellHeight.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DynamicCellHeight ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DynCollViewTableViewCell.swift ├── Info.plist ├── MainTableViewCell.swift ├── Misc.swift ├── MyPickerTableViewCell.swift ├── NotSoGoodDynaTableViewCell.swift ├── NotSoGoodTableViewController.swift ├── SampleTableViewController.swift ├── SampleThreePartTableViewController.swift ├── SecondaryTableViewCell.swift ├── SimpleTableViewCell.swift ├── ThreePartDynaTableViewCell.swift ├── ViewController.swift ├── WithCollViewsTableViewController.swift └── WithPickerTableViewController.swift ├── LICENSE ├── README.md └── caps ├── p1.png └── p2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /DynamicCellHeight.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7C1620871E6F53BB00FF197C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C1620861E6F53BB00FF197C /* AppDelegate.swift */; }; 11 | 7C1620891E6F53BB00FF197C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C1620881E6F53BB00FF197C /* ViewController.swift */; }; 12 | 7C16208C1E6F53BC00FF197C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7C16208A1E6F53BC00FF197C /* Main.storyboard */; }; 13 | 7C16208E1E6F53BC00FF197C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7C16208D1E6F53BC00FF197C /* Assets.xcassets */; }; 14 | 7C1620911E6F53BC00FF197C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7C16208F1E6F53BC00FF197C /* LaunchScreen.storyboard */; }; 15 | 7C729E3C1EAFE2AB00C22170 /* WithPickerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C729E3B1EAFE2AB00C22170 /* WithPickerTableViewController.swift */; }; 16 | 7C729E3E1EAFE42800C22170 /* MyPickerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C729E3D1EAFE42800C22170 /* MyPickerTableViewCell.swift */; }; 17 | 7C76F85D1E8C083E0041733B /* NotSoGoodDynaTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76F85C1E8C083E0041733B /* NotSoGoodDynaTableViewCell.swift */; }; 18 | 7C76F85F1E8C09400041733B /* NotSoGoodTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76F85E1E8C09400041733B /* NotSoGoodTableViewController.swift */; }; 19 | 7CAE41C41E7099480023BA8B /* SampleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CAE41C31E7099480023BA8B /* SampleTableViewController.swift */; }; 20 | 7CAE41C61E7099670023BA8B /* MainTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CAE41C51E7099670023BA8B /* MainTableViewCell.swift */; }; 21 | 7CAE41C81E7099760023BA8B /* SecondaryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CAE41C71E7099760023BA8B /* SecondaryTableViewCell.swift */; }; 22 | 7CD145791E845CDC005BFF6F /* ThreePartDynaTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD145781E845CDC005BFF6F /* ThreePartDynaTableViewCell.swift */; }; 23 | 7CD1457B1E845D14005BFF6F /* SampleThreePartTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD1457A1E845D14005BFF6F /* SampleThreePartTableViewController.swift */; }; 24 | 7CE0BCCA1E9BACE70008C415 /* WithCollViewsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0BCC91E9BACE70008C415 /* WithCollViewsTableViewController.swift */; }; 25 | 7CE0BCCE1E9BB1DF0008C415 /* SimpleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0BCCD1E9BB1DF0008C415 /* SimpleTableViewCell.swift */; }; 26 | 7CE0BCD01E9BBC280008C415 /* DynCollViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0BCCF1E9BBC280008C415 /* DynCollViewTableViewCell.swift */; }; 27 | 7CE0BCD21E9BC1FA0008C415 /* Misc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0BCD11E9BC1FA0008C415 /* Misc.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 7C1620831E6F53BB00FF197C /* DynamicCellHeight.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DynamicCellHeight.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 7C1620861E6F53BB00FF197C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 7C1620881E6F53BB00FF197C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | 7C16208B1E6F53BC00FF197C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 7C16208D1E6F53BC00FF197C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 36 | 7C1620901E6F53BC00FF197C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 37 | 7C1620921E6F53BC00FF197C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 7C729E3B1EAFE2AB00C22170 /* WithPickerTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithPickerTableViewController.swift; sourceTree = ""; }; 39 | 7C729E3D1EAFE42800C22170 /* MyPickerTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyPickerTableViewCell.swift; sourceTree = ""; }; 40 | 7C76F85C1E8C083E0041733B /* NotSoGoodDynaTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotSoGoodDynaTableViewCell.swift; sourceTree = ""; }; 41 | 7C76F85E1E8C09400041733B /* NotSoGoodTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotSoGoodTableViewController.swift; sourceTree = ""; }; 42 | 7CAE41C31E7099480023BA8B /* SampleTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleTableViewController.swift; sourceTree = ""; }; 43 | 7CAE41C51E7099670023BA8B /* MainTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTableViewCell.swift; sourceTree = ""; }; 44 | 7CAE41C71E7099760023BA8B /* SecondaryTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondaryTableViewCell.swift; sourceTree = ""; }; 45 | 7CD145781E845CDC005BFF6F /* ThreePartDynaTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThreePartDynaTableViewCell.swift; sourceTree = ""; }; 46 | 7CD1457A1E845D14005BFF6F /* SampleThreePartTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleThreePartTableViewController.swift; sourceTree = ""; }; 47 | 7CE0BCC91E9BACE70008C415 /* WithCollViewsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithCollViewsTableViewController.swift; sourceTree = ""; }; 48 | 7CE0BCCD1E9BB1DF0008C415 /* SimpleTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleTableViewCell.swift; sourceTree = ""; }; 49 | 7CE0BCCF1E9BBC280008C415 /* DynCollViewTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynCollViewTableViewCell.swift; sourceTree = ""; }; 50 | 7CE0BCD11E9BC1FA0008C415 /* Misc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Misc.swift; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 7C1620801E6F53BB00FF197C /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 7C16207A1E6F53BB00FF197C = { 65 | isa = PBXGroup; 66 | children = ( 67 | 7C1620851E6F53BB00FF197C /* DynamicCellHeight */, 68 | 7C1620841E6F53BB00FF197C /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 7C1620841E6F53BB00FF197C /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 7C1620831E6F53BB00FF197C /* DynamicCellHeight.app */, 76 | ); 77 | name = Products; 78 | sourceTree = ""; 79 | }; 80 | 7C1620851E6F53BB00FF197C /* DynamicCellHeight */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 7C1620861E6F53BB00FF197C /* AppDelegate.swift */, 84 | 7C1620881E6F53BB00FF197C /* ViewController.swift */, 85 | 7C16208A1E6F53BC00FF197C /* Main.storyboard */, 86 | 7C16208D1E6F53BC00FF197C /* Assets.xcassets */, 87 | 7C16208F1E6F53BC00FF197C /* LaunchScreen.storyboard */, 88 | 7C1620921E6F53BC00FF197C /* Info.plist */, 89 | 7C76F85A1E8C07C20041733B /* Table A Example */, 90 | 7C76F85B1E8C07DD0041733B /* Table B Example */, 91 | 7C76F8601E8C09480041733B /* NotSoGood Table B */, 92 | 7CE0BCD31E9BCF820008C415 /* Table With Collection View */, 93 | 7CE0BCD11E9BC1FA0008C415 /* Misc.swift */, 94 | 7C729E3F1EAFF14700C22170 /* Cells with PickerView */, 95 | ); 96 | path = DynamicCellHeight; 97 | sourceTree = ""; 98 | }; 99 | 7C729E3F1EAFF14700C22170 /* Cells with PickerView */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 7C729E3B1EAFE2AB00C22170 /* WithPickerTableViewController.swift */, 103 | 7C729E3D1EAFE42800C22170 /* MyPickerTableViewCell.swift */, 104 | ); 105 | name = "Cells with PickerView"; 106 | sourceTree = ""; 107 | }; 108 | 7C76F85A1E8C07C20041733B /* Table A Example */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 7CAE41C31E7099480023BA8B /* SampleTableViewController.swift */, 112 | 7CAE41C51E7099670023BA8B /* MainTableViewCell.swift */, 113 | 7CAE41C71E7099760023BA8B /* SecondaryTableViewCell.swift */, 114 | ); 115 | name = "Table A Example"; 116 | sourceTree = ""; 117 | }; 118 | 7C76F85B1E8C07DD0041733B /* Table B Example */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 7CD145781E845CDC005BFF6F /* ThreePartDynaTableViewCell.swift */, 122 | 7CD1457A1E845D14005BFF6F /* SampleThreePartTableViewController.swift */, 123 | ); 124 | name = "Table B Example"; 125 | sourceTree = ""; 126 | }; 127 | 7C76F8601E8C09480041733B /* NotSoGood Table B */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 7C76F85C1E8C083E0041733B /* NotSoGoodDynaTableViewCell.swift */, 131 | 7C76F85E1E8C09400041733B /* NotSoGoodTableViewController.swift */, 132 | ); 133 | name = "NotSoGood Table B"; 134 | sourceTree = ""; 135 | }; 136 | 7CE0BCD31E9BCF820008C415 /* Table With Collection View */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 7CE0BCC91E9BACE70008C415 /* WithCollViewsTableViewController.swift */, 140 | 7CE0BCCD1E9BB1DF0008C415 /* SimpleTableViewCell.swift */, 141 | 7CE0BCCF1E9BBC280008C415 /* DynCollViewTableViewCell.swift */, 142 | ); 143 | name = "Table With Collection View"; 144 | sourceTree = ""; 145 | }; 146 | /* End PBXGroup section */ 147 | 148 | /* Begin PBXNativeTarget section */ 149 | 7C1620821E6F53BB00FF197C /* DynamicCellHeight */ = { 150 | isa = PBXNativeTarget; 151 | buildConfigurationList = 7C1620951E6F53BC00FF197C /* Build configuration list for PBXNativeTarget "DynamicCellHeight" */; 152 | buildPhases = ( 153 | 7C16207F1E6F53BB00FF197C /* Sources */, 154 | 7C1620801E6F53BB00FF197C /* Frameworks */, 155 | 7C1620811E6F53BB00FF197C /* Resources */, 156 | ); 157 | buildRules = ( 158 | ); 159 | dependencies = ( 160 | ); 161 | name = DynamicCellHeight; 162 | productName = DynamicCellHeight; 163 | productReference = 7C1620831E6F53BB00FF197C /* DynamicCellHeight.app */; 164 | productType = "com.apple.product-type.application"; 165 | }; 166 | /* End PBXNativeTarget section */ 167 | 168 | /* Begin PBXProject section */ 169 | 7C16207B1E6F53BB00FF197C /* Project object */ = { 170 | isa = PBXProject; 171 | attributes = { 172 | LastSwiftUpdateCheck = 0820; 173 | LastUpgradeCheck = 0820; 174 | ORGANIZATIONNAME = DonMag; 175 | TargetAttributes = { 176 | 7C1620821E6F53BB00FF197C = { 177 | CreatedOnToolsVersion = 8.2.1; 178 | ProvisioningStyle = Automatic; 179 | }; 180 | }; 181 | }; 182 | buildConfigurationList = 7C16207E1E6F53BB00FF197C /* Build configuration list for PBXProject "DynamicCellHeight" */; 183 | compatibilityVersion = "Xcode 3.2"; 184 | developmentRegion = English; 185 | hasScannedForEncodings = 0; 186 | knownRegions = ( 187 | en, 188 | Base, 189 | ); 190 | mainGroup = 7C16207A1E6F53BB00FF197C; 191 | productRefGroup = 7C1620841E6F53BB00FF197C /* Products */; 192 | projectDirPath = ""; 193 | projectRoot = ""; 194 | targets = ( 195 | 7C1620821E6F53BB00FF197C /* DynamicCellHeight */, 196 | ); 197 | }; 198 | /* End PBXProject section */ 199 | 200 | /* Begin PBXResourcesBuildPhase section */ 201 | 7C1620811E6F53BB00FF197C /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | 7C1620911E6F53BC00FF197C /* LaunchScreen.storyboard in Resources */, 206 | 7C16208E1E6F53BC00FF197C /* Assets.xcassets in Resources */, 207 | 7C16208C1E6F53BC00FF197C /* Main.storyboard in Resources */, 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | }; 211 | /* End PBXResourcesBuildPhase section */ 212 | 213 | /* Begin PBXSourcesBuildPhase section */ 214 | 7C16207F1E6F53BB00FF197C /* Sources */ = { 215 | isa = PBXSourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | 7CD145791E845CDC005BFF6F /* ThreePartDynaTableViewCell.swift in Sources */, 219 | 7CAE41C81E7099760023BA8B /* SecondaryTableViewCell.swift in Sources */, 220 | 7C729E3E1EAFE42800C22170 /* MyPickerTableViewCell.swift in Sources */, 221 | 7C1620891E6F53BB00FF197C /* ViewController.swift in Sources */, 222 | 7CAE41C61E7099670023BA8B /* MainTableViewCell.swift in Sources */, 223 | 7C76F85D1E8C083E0041733B /* NotSoGoodDynaTableViewCell.swift in Sources */, 224 | 7C76F85F1E8C09400041733B /* NotSoGoodTableViewController.swift in Sources */, 225 | 7CE0BCCA1E9BACE70008C415 /* WithCollViewsTableViewController.swift in Sources */, 226 | 7C1620871E6F53BB00FF197C /* AppDelegate.swift in Sources */, 227 | 7CD1457B1E845D14005BFF6F /* SampleThreePartTableViewController.swift in Sources */, 228 | 7C729E3C1EAFE2AB00C22170 /* WithPickerTableViewController.swift in Sources */, 229 | 7CE0BCD01E9BBC280008C415 /* DynCollViewTableViewCell.swift in Sources */, 230 | 7CE0BCCE1E9BB1DF0008C415 /* SimpleTableViewCell.swift in Sources */, 231 | 7CE0BCD21E9BC1FA0008C415 /* Misc.swift in Sources */, 232 | 7CAE41C41E7099480023BA8B /* SampleTableViewController.swift in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXVariantGroup section */ 239 | 7C16208A1E6F53BC00FF197C /* Main.storyboard */ = { 240 | isa = PBXVariantGroup; 241 | children = ( 242 | 7C16208B1E6F53BC00FF197C /* Base */, 243 | ); 244 | name = Main.storyboard; 245 | sourceTree = ""; 246 | }; 247 | 7C16208F1E6F53BC00FF197C /* LaunchScreen.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 7C1620901E6F53BC00FF197C /* Base */, 251 | ); 252 | name = LaunchScreen.storyboard; 253 | sourceTree = ""; 254 | }; 255 | /* End PBXVariantGroup section */ 256 | 257 | /* Begin XCBuildConfiguration section */ 258 | 7C1620931E6F53BC00FF197C /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | CLANG_ANALYZER_NONNULL = YES; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BOOL_CONVERSION = YES; 268 | CLANG_WARN_CONSTANT_CONVERSION = YES; 269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 270 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 271 | CLANG_WARN_EMPTY_BODY = YES; 272 | CLANG_WARN_ENUM_CONVERSION = YES; 273 | CLANG_WARN_INFINITE_RECURSION = YES; 274 | CLANG_WARN_INT_CONVERSION = YES; 275 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 276 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | DEBUG_INFORMATION_FORMAT = dwarf; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | ENABLE_TESTABILITY = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu99; 285 | GCC_DYNAMIC_NO_PIC = NO; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_OPTIMIZATION_LEVEL = 0; 288 | GCC_PREPROCESSOR_DEFINITIONS = ( 289 | "DEBUG=1", 290 | "$(inherited)", 291 | ); 292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 294 | GCC_WARN_UNDECLARED_SELECTOR = YES; 295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 296 | GCC_WARN_UNUSED_FUNCTION = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 299 | MTL_ENABLE_DEBUG_INFO = YES; 300 | ONLY_ACTIVE_ARCH = YES; 301 | SDKROOT = iphoneos; 302 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 303 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 304 | TARGETED_DEVICE_FAMILY = "1,2"; 305 | }; 306 | name = Debug; 307 | }; 308 | 7C1620941E6F53BC00FF197C /* Release */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | ALWAYS_SEARCH_USER_PATHS = NO; 312 | CLANG_ANALYZER_NONNULL = YES; 313 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 314 | CLANG_CXX_LIBRARY = "libc++"; 315 | CLANG_ENABLE_MODULES = YES; 316 | CLANG_ENABLE_OBJC_ARC = YES; 317 | CLANG_WARN_BOOL_CONVERSION = YES; 318 | CLANG_WARN_CONSTANT_CONVERSION = YES; 319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 320 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 321 | CLANG_WARN_EMPTY_BODY = YES; 322 | CLANG_WARN_ENUM_CONVERSION = YES; 323 | CLANG_WARN_INFINITE_RECURSION = YES; 324 | CLANG_WARN_INT_CONVERSION = YES; 325 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 326 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 327 | CLANG_WARN_UNREACHABLE_CODE = YES; 328 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 329 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 330 | COPY_PHASE_STRIP = NO; 331 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 332 | ENABLE_NS_ASSERTIONS = NO; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | GCC_C_LANGUAGE_STANDARD = gnu99; 335 | GCC_NO_COMMON_BLOCKS = YES; 336 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 337 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 338 | GCC_WARN_UNDECLARED_SELECTOR = YES; 339 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 340 | GCC_WARN_UNUSED_FUNCTION = YES; 341 | GCC_WARN_UNUSED_VARIABLE = YES; 342 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 343 | MTL_ENABLE_DEBUG_INFO = NO; 344 | SDKROOT = iphoneos; 345 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 346 | TARGETED_DEVICE_FAMILY = "1,2"; 347 | VALIDATE_PRODUCT = YES; 348 | }; 349 | name = Release; 350 | }; 351 | 7C1620961E6F53BC00FF197C /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 355 | INFOPLIST_FILE = DynamicCellHeight/Info.plist; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 357 | PRODUCT_BUNDLE_IDENTIFIER = com.DonMag.DynamicCellHeight; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | SWIFT_VERSION = 3.0; 360 | }; 361 | name = Debug; 362 | }; 363 | 7C1620971E6F53BC00FF197C /* Release */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 367 | INFOPLIST_FILE = DynamicCellHeight/Info.plist; 368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 369 | PRODUCT_BUNDLE_IDENTIFIER = com.DonMag.DynamicCellHeight; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | SWIFT_VERSION = 3.0; 372 | }; 373 | name = Release; 374 | }; 375 | /* End XCBuildConfiguration section */ 376 | 377 | /* Begin XCConfigurationList section */ 378 | 7C16207E1E6F53BB00FF197C /* Build configuration list for PBXProject "DynamicCellHeight" */ = { 379 | isa = XCConfigurationList; 380 | buildConfigurations = ( 381 | 7C1620931E6F53BC00FF197C /* Debug */, 382 | 7C1620941E6F53BC00FF197C /* Release */, 383 | ); 384 | defaultConfigurationIsVisible = 0; 385 | defaultConfigurationName = Release; 386 | }; 387 | 7C1620951E6F53BC00FF197C /* Build configuration list for PBXNativeTarget "DynamicCellHeight" */ = { 388 | isa = XCConfigurationList; 389 | buildConfigurations = ( 390 | 7C1620961E6F53BC00FF197C /* Debug */, 391 | 7C1620971E6F53BC00FF197C /* Release */, 392 | ); 393 | defaultConfigurationIsVisible = 0; 394 | defaultConfigurationName = Release; 395 | }; 396 | /* End XCConfigurationList section */ 397 | }; 398 | rootObject = 7C16207B1E6F53BB00FF197C /* Project object */; 399 | } 400 | -------------------------------------------------------------------------------- /DynamicCellHeight.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DynamicCellHeight/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/7/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DynamicCellHeight/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DynamicCellHeight/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DynamicCellHeight/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 35 | 42 | 49 | 56 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 153 | 159 | 160 | 161 | 167 | 168 | 169 | 170 | 176 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 360 | 366 | 367 | 368 | 369 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 473 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 669 | 675 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | -------------------------------------------------------------------------------- /DynamicCellHeight/DynCollViewTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DynCollViewTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/10/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CollViewCell: UICollectionViewCell { 12 | @IBOutlet weak var theLabel: UILabel! 13 | } 14 | 15 | class DynCollViewTableViewCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { 16 | 17 | @IBOutlet weak var theCollectionView: UICollectionView! 18 | @IBOutlet weak var theCVHeight: NSLayoutConstraint! 19 | 20 | var vContentSize: CGSize = CGSize.zero 21 | 22 | override func awakeFromNib() { 23 | super.awakeFromNib() 24 | // Initialization code 25 | } 26 | 27 | override func setSelected(_ selected: Bool, animated: Bool) { 28 | super.setSelected(selected, animated: animated) 29 | } 30 | 31 | 32 | // MARK: UICollectionViewDataSource 33 | func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { 34 | return 1 35 | } 36 | 37 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 38 | let t = Int(arc4random_uniform(27)) + 3 39 | return t 40 | } 41 | 42 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 43 | 44 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "colCell", for: indexPath) as! CollViewCell 45 | 46 | let c = UIColor.randomColor() 47 | cell.backgroundColor = c 48 | cell.theLabel.textColor = c.isDark ? UIColor.white : UIColor.black 49 | 50 | cell.theLabel.text = "\(indexPath.row)" 51 | 52 | if collectionView.contentSize != vContentSize { 53 | vContentSize = collectionView.contentSize 54 | theCVHeight.constant = vContentSize.height 55 | } 56 | 57 | return cell 58 | } 59 | 60 | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 61 | return CGSize(width: 100, height: 60) 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DynamicCellHeight/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DynamicCellHeight/MainTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/8/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | protocol MainCellDelegate { 13 | func switchChanged(sender: UISwitch, cell: MainTableViewCell) 14 | } 15 | 16 | class MainTableViewCell: UITableViewCell { 17 | 18 | @IBOutlet weak var sizer: NSLayoutConstraint! 19 | 20 | var delegate: MainCellDelegate? 21 | 22 | var expandedSize: CGFloat = 0.0 23 | 24 | @IBAction func didChangeSwitch(_ sender: Any) { 25 | 26 | if let t = sender as? UISwitch { 27 | self.sizer.constant = t.isOn ? self.expandedSize : 0.0 28 | delegate?.switchChanged(sender: t, cell: self) 29 | } 30 | 31 | } 32 | 33 | override func awakeFromNib() { 34 | super.awakeFromNib() 35 | // Initialization code 36 | self.expandedSize = sizer.constant 37 | } 38 | 39 | override func setSelected(_ selected: Bool, animated: Bool) { 40 | super.setSelected(selected, animated: animated) 41 | 42 | // Configure the view for the selected state 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /DynamicCellHeight/Misc.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Misc.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/10/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIColor { 12 | 13 | class func randomColor() -> UIColor { 14 | 15 | let r = CGFloat(arc4random_uniform(255)) / 255.0 16 | let g = CGFloat(arc4random_uniform(255)) / 255.0 17 | let b = CGFloat(arc4random_uniform(255)) / 255.0 18 | 19 | return UIColor(red: r, green: g, blue: b, alpha: 1.0) 20 | } 21 | 22 | var isDark: Bool { 23 | var white: CGFloat = 0 24 | getWhite(&white, alpha: nil) 25 | return white < 0.5 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /DynamicCellHeight/MyPickerTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyPickerTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/25/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MyPickerTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var theLabelsContainer: UIView! 14 | @IBOutlet weak var startEndLabel: UILabel! 15 | @IBOutlet weak var theTimeLabel: UILabel! 16 | 17 | @IBOutlet weak var theDatePicker: UIDatePicker! 18 | 19 | @IBOutlet weak var pickerHeightConstraint: NSLayoutConstraint! 20 | 21 | 22 | override func awakeFromNib() { 23 | super.awakeFromNib() 24 | // Initialization code 25 | 26 | pickerHeightConstraint.constant = 32 27 | } 28 | 29 | override func setSelected(_ selected: Bool, animated: Bool) { 30 | super.setSelected(selected, animated: animated) 31 | 32 | // Configure the view for the selected state 33 | 34 | theLabelsContainer.backgroundColor = selected ? UIColor.gray : UIColor.clear 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /DynamicCellHeight/NotSoGoodDynaTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotSoGoodDynaTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/29/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol NotSoGoodCellDelegate { 12 | func moreTapped(cell: NotSoGoodDynaTableViewCell) 13 | } 14 | 15 | 16 | class NotSoGoodDynaTableViewCell: UITableViewCell { 17 | 18 | @IBOutlet weak var labelTitle: UILabel! 19 | @IBOutlet weak var labelBody: UILabel! 20 | 21 | @IBOutlet weak var buttonMore: UIButton! 22 | 23 | var delegate: NotSoGoodCellDelegate? 24 | 25 | var isExpanded: Bool = false 26 | 27 | @IBAction func btnMoreTapped(_ sender: Any) { 28 | 29 | if sender is UIButton { 30 | isExpanded = !isExpanded 31 | 32 | labelBody.numberOfLines = isExpanded ? 0 : 2 33 | buttonMore.setTitle(isExpanded ? "Read less..." : "Read more...", for: .normal) 34 | 35 | delegate?.moreTapped(cell: self) 36 | } 37 | 38 | } 39 | 40 | public func myInit(theTitle: String, theBody: String) { 41 | 42 | isExpanded = false 43 | 44 | labelTitle.text = theTitle 45 | labelBody.text = theBody 46 | 47 | labelBody.numberOfLines = 2 48 | 49 | } 50 | 51 | override func awakeFromNib() { 52 | super.awakeFromNib() 53 | // Initialization code 54 | } 55 | 56 | override func setSelected(_ selected: Bool, animated: Bool) { 57 | super.setSelected(selected, animated: animated) 58 | 59 | // Configure the view for the selected state 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /DynamicCellHeight/NotSoGoodTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotSoGoodTableViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/29/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NotSoGoodTableViewController: UITableViewController, NotSoGoodCellDelegate { 12 | 13 | var myArray = [String]() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | self.tableView.rowHeight = UITableViewAutomaticDimension 19 | self.tableView.estimatedRowHeight = 100; //Set this to any value that works for you. 20 | 21 | // create some random data 22 | for _ in 1...15 { 23 | 24 | let n = arc4random_uniform(6) + 4 25 | var str = "" 26 | for i in 1.. Int { 56 | // #warning Incomplete implementation, return the number of sections 57 | return 1 58 | } 59 | 60 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 61 | // #warning Incomplete implementation, return the number of rows 62 | return myArray.count 63 | } 64 | 65 | 66 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 67 | 68 | let cell = tableView.dequeueReusableCell(withIdentifier: "notSoGoodCellID", for: indexPath) as! NotSoGoodDynaTableViewCell 69 | 70 | // Configure the cell... 71 | 72 | let str = myArray[indexPath.row] 73 | let aTmp = str.components(separatedBy: "\n") 74 | 75 | cell.myInit(theTitle: "\(indexPath) with \(aTmp.count) rows", theBody: str) 76 | 77 | cell.delegate = self 78 | 79 | return cell 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /DynamicCellHeight/SampleTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SampleTableViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/8/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SampleTableViewController: UITableViewController, MainCellDelegate { 12 | 13 | let masterCellRow:Int = 3 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | self.tableView.rowHeight = UITableViewAutomaticDimension 19 | self.tableView.estimatedRowHeight = 100; //Set this to any value that works for you. 20 | 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | // MARK: - MainCellDelegate functions 30 | 31 | func switchChanged(sender: UISwitch, cell: MainTableViewCell) { 32 | 33 | // this will "refresh" the row heights, without reloading 34 | tableView.beginUpdates() 35 | tableView.endUpdates() 36 | 37 | // do anything else you want because the switch was changed 38 | 39 | } 40 | 41 | // MARK: - Table view data source 42 | 43 | override func numberOfSections(in tableView: UITableView) -> Int { 44 | return 1 45 | } 46 | 47 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 48 | return 15 49 | } 50 | 51 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 52 | 53 | if indexPath.row == masterCellRow { 54 | 55 | let cell = tableView.dequeueReusableCell(withIdentifier: "MainCell", for: indexPath) as! MainTableViewCell 56 | 57 | cell.selectionStyle = UITableViewCellSelectionStyle.none 58 | 59 | cell.delegate = self 60 | 61 | // un-comment the following to remove the "dev colors" 62 | // cell.contentView.backgroundColor = UIColor.clear 63 | // for v in cell.contentView.subviews { 64 | // v.backgroundColor = UIColor.clear 65 | // } 66 | 67 | return cell 68 | 69 | } 70 | 71 | let cell = tableView.dequeueReusableCell(withIdentifier: "SecondaryCell", for: indexPath) as! SecondaryTableViewCell 72 | 73 | switch indexPath.row % 4 { 74 | case 1: 75 | cell.theLabel?.text = "IndexPath for this row: \(indexPath)\nWith a Second Line" 76 | break 77 | case 2: 78 | cell.theLabel?.text = "IndexPath for this row: \(indexPath)\nWith a Second Line\nand a Third Line" 79 | break 80 | case 3: 81 | cell.theLabel?.text = "IndexPath for this row: \(indexPath)\nWith a Second Line that is long enough to wrap onto one or two more lines, just to show that the cells / rows are, in fact, auto-sizing themselves." 82 | break 83 | default: 84 | cell.theLabel?.text = "IndexPath for this row: \(indexPath)" 85 | break 86 | } 87 | 88 | cell.selectionStyle = UITableViewCellSelectionStyle.none 89 | 90 | return cell 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /DynamicCellHeight/SampleThreePartTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SampleThreePartTableViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/23/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SampleThreePartTableViewController: UITableViewController, ThreePartCellDelegate { 12 | 13 | var myArray = [String]() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | self.tableView.rowHeight = UITableViewAutomaticDimension 19 | self.tableView.estimatedRowHeight = 100; //Set this to any value that works for you. 20 | 21 | // create some random data 22 | for _ in 1...15 { 23 | 24 | let n = arc4random_uniform(6) + 4 25 | var str = "" 26 | for i in 1.. Int { 56 | // #warning Incomplete implementation, return the number of sections 57 | return 1 58 | } 59 | 60 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 61 | // #warning Incomplete implementation, return the number of rows 62 | return myArray.count 63 | } 64 | 65 | 66 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 67 | 68 | let cell = tableView.dequeueReusableCell(withIdentifier: "threePartCellID", for: indexPath) as! ThreePartDynaTableViewCell 69 | 70 | // Configure the cell... 71 | 72 | let str = myArray[indexPath.row] 73 | let aTmp = str.components(separatedBy: "\n") 74 | 75 | cell.myInit(theTitle: "\(indexPath) with \(aTmp.count) rows", theBody: str) 76 | 77 | cell.delegate = self 78 | 79 | return cell 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /DynamicCellHeight/SecondaryTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondaryTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/8/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SecondaryTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var theLabel: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | // Initialization code 18 | } 19 | 20 | override func setSelected(_ selected: Bool, animated: Bool) { 21 | super.setSelected(selected, animated: animated) 22 | 23 | // Configure the view for the selected state 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /DynamicCellHeight/SimpleTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/10/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SimpleTableViewCell: UITableViewCell { 12 | 13 | 14 | @IBOutlet weak var theLabel: UILabel! 15 | 16 | override func awakeFromNib() { 17 | super.awakeFromNib() 18 | // Initialization code 19 | } 20 | 21 | override func setSelected(_ selected: Bool, animated: Bool) { 22 | super.setSelected(selected, animated: animated) 23 | 24 | // Configure the view for the selected state 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /DynamicCellHeight/ThreePartDynaTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ThreePartDynaTableViewCell.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/23/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol ThreePartCellDelegate { 12 | func moreTapped(cell: ThreePartDynaTableViewCell) 13 | } 14 | 15 | class ThreePartDynaTableViewCell: UITableViewCell { 16 | 17 | @IBOutlet weak var labelTitle: UILabel! 18 | @IBOutlet weak var labelBody: UILabel! 19 | 20 | @IBOutlet weak var buttonMore: UIButton! 21 | 22 | @IBOutlet weak var sizingLabel: UILabel! 23 | 24 | 25 | var delegate: ThreePartCellDelegate? 26 | 27 | var isExpanded: Bool = false 28 | 29 | @IBAction func btnMoreTapped(_ sender: Any) { 30 | 31 | if sender is UIButton { 32 | isExpanded = !isExpanded 33 | 34 | sizingLabel.numberOfLines = isExpanded ? 0 : 2 35 | buttonMore.setTitle(isExpanded ? "Read less..." : "Read more...", for: .normal) 36 | 37 | delegate?.moreTapped(cell: self) 38 | } 39 | 40 | } 41 | 42 | public func myInit(theTitle: String, theBody: String) { 43 | 44 | isExpanded = false 45 | 46 | labelTitle.text = theTitle 47 | labelBody.text = theBody 48 | 49 | labelBody.numberOfLines = 0 50 | 51 | sizingLabel.text = theBody 52 | sizingLabel.numberOfLines = 2 53 | 54 | } 55 | 56 | override func awakeFromNib() { 57 | super.awakeFromNib() 58 | // Initialization code 59 | } 60 | 61 | override func setSelected(_ selected: Bool, animated: Bool) { 62 | super.setSelected(selected, animated: animated) 63 | 64 | // Configure the view for the selected state 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /DynamicCellHeight/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 3/7/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /DynamicCellHeight/WithCollViewsTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WithCollViewsTableViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/10/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class WithCollViewsTableViewController: UITableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.tableView.rowHeight = UITableViewAutomaticDimension 17 | self.tableView.estimatedRowHeight = 100; 18 | 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | override func viewWillAppear(_ animated: Bool) { 27 | super.viewWillAppear(animated) 28 | 29 | tableView.beginUpdates() 30 | tableView.endUpdates() 31 | 32 | } 33 | 34 | // MARK: - Table view data source 35 | 36 | override func numberOfSections(in tableView: UITableView) -> Int { 37 | return 1 38 | } 39 | 40 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 41 | return 15 42 | } 43 | 44 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 45 | 46 | // use collectionView cell for 3rd row (zero-based, of course) 47 | if indexPath.row == 2 { 48 | let cell = tableView.dequeueReusableCell(withIdentifier: "dCell", for: indexPath) as! DynCollViewTableViewCell 49 | return cell 50 | } 51 | 52 | let cell = tableView.dequeueReusableCell(withIdentifier: "sCell", for: indexPath) as! SimpleTableViewCell 53 | 54 | // use random 1 to 4 lines of text 55 | let nLines = indexPath.row % 3 56 | 57 | var str = "\(indexPath)" 58 | 59 | if nLines > 0 { 60 | for i in 1...nLines { 61 | str = str + "\nLine \(i)" 62 | } 63 | } 64 | 65 | cell.theLabel.text = str 66 | 67 | return cell 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /DynamicCellHeight/WithPickerTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WithPickerTableViewController.swift 3 | // DynamicCellHeight 4 | // 5 | // Created by Don Mag on 4/25/17. 6 | // Copyright © 2017 DonMag. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class WithPickerTableViewController: UITableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.tableView.rowHeight = UITableViewAutomaticDimension 17 | self.tableView.estimatedRowHeight = 100; 18 | 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | // MARK: - Table view data source 27 | 28 | override func numberOfSections(in tableView: UITableView) -> Int { 29 | // #warning Incomplete implementation, return the number of sections 30 | return 2 31 | } 32 | 33 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 34 | // #warning Incomplete implementation, return the number of rows 35 | return 2 36 | } 37 | 38 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 39 | 40 | if indexPath.section == 0 { 41 | 42 | let cell = tableView.dequeueReusableCell(withIdentifier: "myPickerCell", for: indexPath) as! MyPickerTableViewCell 43 | 44 | cell.startEndLabel.text = (indexPath.row == 0 ? "Start" : "End") + " Time" 45 | 46 | cell.selectionStyle = UITableViewCellSelectionStyle.none 47 | 48 | return cell 49 | 50 | } 51 | 52 | let cell = tableView.dequeueReusableCell(withIdentifier: "plainCell", for: indexPath) 53 | 54 | cell.textLabel?.text = "s/r \(indexPath)" 55 | 56 | return cell 57 | 58 | } 59 | 60 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 61 | 62 | if indexPath.section == 0 { 63 | 64 | if let cell = tableView.cellForRow(at: indexPath) as? MyPickerTableViewCell { 65 | 66 | cell.pickerHeightConstraint.constant = cell.pickerHeightConstraint.constant == 32 ? 240 : 32 67 | tableView.beginUpdates() 68 | tableView.endUpdates() 69 | 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 DonMag 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DynamicCellHeight 2 | 3 | One approach to dynamically changing UITableViewCell content and height. 4 | 5 | Weird colors are just to help identify the elements during dev. 6 | 7 | - Example A shows a cell with multiple elements, where some elements are shown/hidden by changing a control inside the cell. 8 | - Example B shows a cell with "Show more" / "Show less" button to expand/contract the number of lines of text displayed. 9 | - Example C shows a not-so-good varsion of "B" - the animation is not as smooth. 10 | - Example D shows dynamic sizing of a TableViewCell containing a CollectionView with variable content. Each time you load "D" you will get a random number of cells in the Collection (well, random between 3 and 30... enough to demo). 11 | - Example E shows one method of showing / hiding a Date Picker as part of a cell. 12 | -------------------------------------------------------------------------------- /caps/p1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonMag/DynamicCellHeight/0965fb1c433564dcd0f059135095bc973f071fe3/caps/p1.png -------------------------------------------------------------------------------- /caps/p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DonMag/DynamicCellHeight/0965fb1c433564dcd0f059135095bc973f071fe3/caps/p2.png --------------------------------------------------------------------------------