├── LICENSE ├── MagnetDynamicTable.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── ufuk.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── ufuk.xcuserdatad │ └── xcschemes │ ├── MagnetDynamicTable.xcscheme │ └── xcschememanagement.plist ├── MagnetDynamicTable ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── ColumnsViewController.h ├── ColumnsViewController.m ├── DynamicTable.h ├── DynamicTable.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── InnerTableViewController.h ├── InnerTableViewController.m ├── TableViewController.h ├── TableViewController.m ├── TabsViewController.h ├── TabsViewController.m └── main.m ├── MagnetDynamicTableTests ├── Info.plist └── MagnetDynamicTableTests.m └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 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 13 | all 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 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /MagnetDynamicTable.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E112FE9D1AB9AFC1009C6F09 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FE9C1AB9AFC1009C6F09 /* main.m */; }; 11 | E112FEA01AB9AFC1009C6F09 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FE9F1AB9AFC1009C6F09 /* AppDelegate.m */; }; 12 | E112FEA61AB9AFC1009C6F09 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E112FEA41AB9AFC1009C6F09 /* Main.storyboard */; }; 13 | E112FEA81AB9AFC1009C6F09 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E112FEA71AB9AFC1009C6F09 /* Images.xcassets */; }; 14 | E112FEAB1AB9AFC1009C6F09 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = E112FEA91AB9AFC1009C6F09 /* LaunchScreen.xib */; }; 15 | E112FEB71AB9AFC1009C6F09 /* MagnetDynamicTableTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FEB61AB9AFC1009C6F09 /* MagnetDynamicTableTests.m */; }; 16 | E112FEC31AB9B08D009C6F09 /* DynamicTable.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FEC21AB9B08D009C6F09 /* DynamicTable.m */; }; 17 | E112FECD1AB9B0F9009C6F09 /* ColumnsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FEC61AB9B0F9009C6F09 /* ColumnsViewController.m */; }; 18 | E112FECE1AB9B0F9009C6F09 /* InnerTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FEC81AB9B0F9009C6F09 /* InnerTableViewController.m */; }; 19 | E112FECF1AB9B0F9009C6F09 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FECA1AB9B0F9009C6F09 /* TableViewController.m */; }; 20 | E112FED01AB9B0F9009C6F09 /* TabsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E112FECC1AB9B0F9009C6F09 /* TabsViewController.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | E112FEB11AB9AFC1009C6F09 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = E112FE8F1AB9AFC1009C6F09 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = E112FE961AB9AFC1009C6F09; 29 | remoteInfo = MagnetDynamicTable; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | E112FE971AB9AFC1009C6F09 /* MagnetDynamicTable.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MagnetDynamicTable.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | E112FE9B1AB9AFC1009C6F09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | E112FE9C1AB9AFC1009C6F09 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | E112FE9E1AB9AFC1009C6F09 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | E112FE9F1AB9AFC1009C6F09 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | E112FEA51AB9AFC1009C6F09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | E112FEA71AB9AFC1009C6F09 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | E112FEAA1AB9AFC1009C6F09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | E112FEB01AB9AFC1009C6F09 /* MagnetDynamicTableTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MagnetDynamicTableTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | E112FEB51AB9AFC1009C6F09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | E112FEB61AB9AFC1009C6F09 /* MagnetDynamicTableTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MagnetDynamicTableTests.m; sourceTree = ""; }; 45 | E112FEC11AB9B08D009C6F09 /* DynamicTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicTable.h; sourceTree = ""; }; 46 | E112FEC21AB9B08D009C6F09 /* DynamicTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DynamicTable.m; sourceTree = ""; }; 47 | E112FEC51AB9B0F9009C6F09 /* ColumnsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnsViewController.h; sourceTree = ""; }; 48 | E112FEC61AB9B0F9009C6F09 /* ColumnsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColumnsViewController.m; sourceTree = ""; }; 49 | E112FEC71AB9B0F9009C6F09 /* InnerTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InnerTableViewController.h; sourceTree = ""; }; 50 | E112FEC81AB9B0F9009C6F09 /* InnerTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InnerTableViewController.m; sourceTree = ""; }; 51 | E112FEC91AB9B0F9009C6F09 /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = ""; }; 52 | E112FECA1AB9B0F9009C6F09 /* TableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewController.m; sourceTree = ""; }; 53 | E112FECB1AB9B0F9009C6F09 /* TabsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabsViewController.h; sourceTree = ""; }; 54 | E112FECC1AB9B0F9009C6F09 /* TabsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabsViewController.m; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | E112FE941AB9AFC1009C6F09 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | E112FEAD1AB9AFC1009C6F09 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | E112FE8E1AB9AFC1009C6F09 = { 76 | isa = PBXGroup; 77 | children = ( 78 | E112FE991AB9AFC1009C6F09 /* MagnetDynamicTable */, 79 | E112FEB31AB9AFC1009C6F09 /* MagnetDynamicTableTests */, 80 | E112FE981AB9AFC1009C6F09 /* Products */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | E112FE981AB9AFC1009C6F09 /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | E112FE971AB9AFC1009C6F09 /* MagnetDynamicTable.app */, 88 | E112FEB01AB9AFC1009C6F09 /* MagnetDynamicTableTests.xctest */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | E112FE991AB9AFC1009C6F09 /* MagnetDynamicTable */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | E112FEC41AB9B0EA009C6F09 /* Demo */, 97 | E112FEC01AB9B071009C6F09 /* DynamicTable */, 98 | E112FE9E1AB9AFC1009C6F09 /* AppDelegate.h */, 99 | E112FE9F1AB9AFC1009C6F09 /* AppDelegate.m */, 100 | E112FEA41AB9AFC1009C6F09 /* Main.storyboard */, 101 | E112FEA71AB9AFC1009C6F09 /* Images.xcassets */, 102 | E112FEA91AB9AFC1009C6F09 /* LaunchScreen.xib */, 103 | E112FE9A1AB9AFC1009C6F09 /* Supporting Files */, 104 | ); 105 | path = MagnetDynamicTable; 106 | sourceTree = ""; 107 | }; 108 | E112FE9A1AB9AFC1009C6F09 /* Supporting Files */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | E112FE9B1AB9AFC1009C6F09 /* Info.plist */, 112 | E112FE9C1AB9AFC1009C6F09 /* main.m */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | E112FEB31AB9AFC1009C6F09 /* MagnetDynamicTableTests */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | E112FEB61AB9AFC1009C6F09 /* MagnetDynamicTableTests.m */, 121 | E112FEB41AB9AFC1009C6F09 /* Supporting Files */, 122 | ); 123 | path = MagnetDynamicTableTests; 124 | sourceTree = ""; 125 | }; 126 | E112FEB41AB9AFC1009C6F09 /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | E112FEB51AB9AFC1009C6F09 /* Info.plist */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | E112FEC01AB9B071009C6F09 /* DynamicTable */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | E112FEC11AB9B08D009C6F09 /* DynamicTable.h */, 138 | E112FEC21AB9B08D009C6F09 /* DynamicTable.m */, 139 | ); 140 | name = DynamicTable; 141 | sourceTree = ""; 142 | }; 143 | E112FEC41AB9B0EA009C6F09 /* Demo */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | E112FEC51AB9B0F9009C6F09 /* ColumnsViewController.h */, 147 | E112FEC61AB9B0F9009C6F09 /* ColumnsViewController.m */, 148 | E112FEC71AB9B0F9009C6F09 /* InnerTableViewController.h */, 149 | E112FEC81AB9B0F9009C6F09 /* InnerTableViewController.m */, 150 | E112FEC91AB9B0F9009C6F09 /* TableViewController.h */, 151 | E112FECA1AB9B0F9009C6F09 /* TableViewController.m */, 152 | E112FECB1AB9B0F9009C6F09 /* TabsViewController.h */, 153 | E112FECC1AB9B0F9009C6F09 /* TabsViewController.m */, 154 | ); 155 | name = Demo; 156 | sourceTree = ""; 157 | }; 158 | /* End PBXGroup section */ 159 | 160 | /* Begin PBXNativeTarget section */ 161 | E112FE961AB9AFC1009C6F09 /* MagnetDynamicTable */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = E112FEBA1AB9AFC1009C6F09 /* Build configuration list for PBXNativeTarget "MagnetDynamicTable" */; 164 | buildPhases = ( 165 | E112FE931AB9AFC1009C6F09 /* Sources */, 166 | E112FE941AB9AFC1009C6F09 /* Frameworks */, 167 | E112FE951AB9AFC1009C6F09 /* Resources */, 168 | ); 169 | buildRules = ( 170 | ); 171 | dependencies = ( 172 | ); 173 | name = MagnetDynamicTable; 174 | productName = MagnetDynamicTable; 175 | productReference = E112FE971AB9AFC1009C6F09 /* MagnetDynamicTable.app */; 176 | productType = "com.apple.product-type.application"; 177 | }; 178 | E112FEAF1AB9AFC1009C6F09 /* MagnetDynamicTableTests */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = E112FEBD1AB9AFC1009C6F09 /* Build configuration list for PBXNativeTarget "MagnetDynamicTableTests" */; 181 | buildPhases = ( 182 | E112FEAC1AB9AFC1009C6F09 /* Sources */, 183 | E112FEAD1AB9AFC1009C6F09 /* Frameworks */, 184 | E112FEAE1AB9AFC1009C6F09 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | E112FEB21AB9AFC1009C6F09 /* PBXTargetDependency */, 190 | ); 191 | name = MagnetDynamicTableTests; 192 | productName = MagnetDynamicTableTests; 193 | productReference = E112FEB01AB9AFC1009C6F09 /* MagnetDynamicTableTests.xctest */; 194 | productType = "com.apple.product-type.bundle.unit-test"; 195 | }; 196 | /* End PBXNativeTarget section */ 197 | 198 | /* Begin PBXProject section */ 199 | E112FE8F1AB9AFC1009C6F09 /* Project object */ = { 200 | isa = PBXProject; 201 | attributes = { 202 | LastUpgradeCheck = 0610; 203 | ORGANIZATIONNAME = macroismicro; 204 | TargetAttributes = { 205 | E112FE961AB9AFC1009C6F09 = { 206 | CreatedOnToolsVersion = 6.1; 207 | }; 208 | E112FEAF1AB9AFC1009C6F09 = { 209 | CreatedOnToolsVersion = 6.1; 210 | TestTargetID = E112FE961AB9AFC1009C6F09; 211 | }; 212 | }; 213 | }; 214 | buildConfigurationList = E112FE921AB9AFC1009C6F09 /* Build configuration list for PBXProject "MagnetDynamicTable" */; 215 | compatibilityVersion = "Xcode 3.2"; 216 | developmentRegion = English; 217 | hasScannedForEncodings = 0; 218 | knownRegions = ( 219 | en, 220 | Base, 221 | ); 222 | mainGroup = E112FE8E1AB9AFC1009C6F09; 223 | productRefGroup = E112FE981AB9AFC1009C6F09 /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | E112FE961AB9AFC1009C6F09 /* MagnetDynamicTable */, 228 | E112FEAF1AB9AFC1009C6F09 /* MagnetDynamicTableTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | E112FE951AB9AFC1009C6F09 /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | E112FEA61AB9AFC1009C6F09 /* Main.storyboard in Resources */, 239 | E112FEAB1AB9AFC1009C6F09 /* LaunchScreen.xib in Resources */, 240 | E112FEA81AB9AFC1009C6F09 /* Images.xcassets in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | E112FEAE1AB9AFC1009C6F09 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | E112FE931AB9AFC1009C6F09 /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | E112FED01AB9B0F9009C6F09 /* TabsViewController.m in Sources */, 259 | E112FECD1AB9B0F9009C6F09 /* ColumnsViewController.m in Sources */, 260 | E112FEA01AB9AFC1009C6F09 /* AppDelegate.m in Sources */, 261 | E112FEC31AB9B08D009C6F09 /* DynamicTable.m in Sources */, 262 | E112FECE1AB9B0F9009C6F09 /* InnerTableViewController.m in Sources */, 263 | E112FECF1AB9B0F9009C6F09 /* TableViewController.m in Sources */, 264 | E112FE9D1AB9AFC1009C6F09 /* main.m in Sources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | E112FEAC1AB9AFC1009C6F09 /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | E112FEB71AB9AFC1009C6F09 /* MagnetDynamicTableTests.m in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | E112FEB21AB9AFC1009C6F09 /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | target = E112FE961AB9AFC1009C6F09 /* MagnetDynamicTable */; 282 | targetProxy = E112FEB11AB9AFC1009C6F09 /* PBXContainerItemProxy */; 283 | }; 284 | /* End PBXTargetDependency section */ 285 | 286 | /* Begin PBXVariantGroup section */ 287 | E112FEA41AB9AFC1009C6F09 /* Main.storyboard */ = { 288 | isa = PBXVariantGroup; 289 | children = ( 290 | E112FEA51AB9AFC1009C6F09 /* Base */, 291 | ); 292 | name = Main.storyboard; 293 | sourceTree = ""; 294 | }; 295 | E112FEA91AB9AFC1009C6F09 /* LaunchScreen.xib */ = { 296 | isa = PBXVariantGroup; 297 | children = ( 298 | E112FEAA1AB9AFC1009C6F09 /* Base */, 299 | ); 300 | name = LaunchScreen.xib; 301 | sourceTree = ""; 302 | }; 303 | /* End PBXVariantGroup section */ 304 | 305 | /* Begin XCBuildConfiguration section */ 306 | E112FEB81AB9AFC1009C6F09 /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BOOL_CONVERSION = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INT_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 324 | COPY_PHASE_STRIP = NO; 325 | ENABLE_STRICT_OBJC_MSGSEND = YES; 326 | GCC_C_LANGUAGE_STANDARD = gnu99; 327 | GCC_DYNAMIC_NO_PIC = NO; 328 | GCC_OPTIMIZATION_LEVEL = 0; 329 | GCC_PREPROCESSOR_DEFINITIONS = ( 330 | "DEBUG=1", 331 | "$(inherited)", 332 | ); 333 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 334 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 335 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 336 | GCC_WARN_UNDECLARED_SELECTOR = YES; 337 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 338 | GCC_WARN_UNUSED_FUNCTION = YES; 339 | GCC_WARN_UNUSED_VARIABLE = YES; 340 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 341 | MTL_ENABLE_DEBUG_INFO = YES; 342 | ONLY_ACTIVE_ARCH = YES; 343 | SDKROOT = iphoneos; 344 | TARGETED_DEVICE_FAMILY = "1,2"; 345 | }; 346 | name = Debug; 347 | }; 348 | E112FEB91AB9AFC1009C6F09 /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = YES; 367 | ENABLE_NS_ASSERTIONS = NO; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | GCC_C_LANGUAGE_STANDARD = gnu99; 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 377 | MTL_ENABLE_DEBUG_INFO = NO; 378 | SDKROOT = iphoneos; 379 | TARGETED_DEVICE_FAMILY = "1,2"; 380 | VALIDATE_PRODUCT = YES; 381 | }; 382 | name = Release; 383 | }; 384 | E112FEBB1AB9AFC1009C6F09 /* Debug */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | INFOPLIST_FILE = MagnetDynamicTable/Info.plist; 389 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | }; 393 | name = Debug; 394 | }; 395 | E112FEBC1AB9AFC1009C6F09 /* Release */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 399 | INFOPLIST_FILE = MagnetDynamicTable/Info.plist; 400 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | }; 404 | name = Release; 405 | }; 406 | E112FEBE1AB9AFC1009C6F09 /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | BUNDLE_LOADER = "$(TEST_HOST)"; 410 | FRAMEWORK_SEARCH_PATHS = ( 411 | "$(SDKROOT)/Developer/Library/Frameworks", 412 | "$(inherited)", 413 | ); 414 | GCC_PREPROCESSOR_DEFINITIONS = ( 415 | "DEBUG=1", 416 | "$(inherited)", 417 | ); 418 | INFOPLIST_FILE = MagnetDynamicTableTests/Info.plist; 419 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 420 | PRODUCT_NAME = "$(TARGET_NAME)"; 421 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MagnetDynamicTable.app/MagnetDynamicTable"; 422 | }; 423 | name = Debug; 424 | }; 425 | E112FEBF1AB9AFC1009C6F09 /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | BUNDLE_LOADER = "$(TEST_HOST)"; 429 | FRAMEWORK_SEARCH_PATHS = ( 430 | "$(SDKROOT)/Developer/Library/Frameworks", 431 | "$(inherited)", 432 | ); 433 | INFOPLIST_FILE = MagnetDynamicTableTests/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MagnetDynamicTable.app/MagnetDynamicTable"; 437 | }; 438 | name = Release; 439 | }; 440 | /* End XCBuildConfiguration section */ 441 | 442 | /* Begin XCConfigurationList section */ 443 | E112FE921AB9AFC1009C6F09 /* Build configuration list for PBXProject "MagnetDynamicTable" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | E112FEB81AB9AFC1009C6F09 /* Debug */, 447 | E112FEB91AB9AFC1009C6F09 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | E112FEBA1AB9AFC1009C6F09 /* Build configuration list for PBXNativeTarget "MagnetDynamicTable" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | E112FEBB1AB9AFC1009C6F09 /* Debug */, 456 | E112FEBC1AB9AFC1009C6F09 /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | E112FEBD1AB9AFC1009C6F09 /* Build configuration list for PBXNativeTarget "MagnetDynamicTableTests" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | E112FEBE1AB9AFC1009C6F09 /* Debug */, 465 | E112FEBF1AB9AFC1009C6F09 /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | /* End XCConfigurationList section */ 471 | }; 472 | rootObject = E112FE8F1AB9AFC1009C6F09 /* Project object */; 473 | } 474 | -------------------------------------------------------------------------------- /MagnetDynamicTable.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MagnetDynamicTable.xcodeproj/project.xcworkspace/xcuserdata/ufuk.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ufukk/MagnetDynamicTable/0a245f79c3aa1a82a1d94c7fb87f2768102f89ab/MagnetDynamicTable.xcodeproj/project.xcworkspace/xcuserdata/ufuk.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MagnetDynamicTable.xcodeproj/xcuserdata/ufuk.xcuserdatad/xcschemes/MagnetDynamicTable.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /MagnetDynamicTable.xcodeproj/xcuserdata/ufuk.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MagnetDynamicTable.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E112FE961AB9AFC1009C6F09 16 | 17 | primary 18 | 19 | 20 | E112FEAF1AB9AFC1009C6F09 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MagnetDynamicTable/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 18/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MagnetDynamicTable/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 18/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MagnetDynamicTable/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /MagnetDynamicTable/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 | -------------------------------------------------------------------------------- /MagnetDynamicTable/ColumnsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnsViewController.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 15/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ColumnsViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MagnetDynamicTable/ColumnsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColumnsViewController.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 15/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "ColumnsViewController.h" 10 | #import "DynamicTable.h" 11 | 12 | @interface ColumnsViewController () 13 | 14 | @end 15 | 16 | @implementation ColumnsViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | 22 | DynamicTable *table = [[DynamicTable alloc] initWithFrame:CGRectMake(50, 50, 600, 100) columnWidths:@[[NSNumber numberWithFloat:380.0], [NSNumber numberWithFloat:200.0]] cellMargin:5 title:nil]; 23 | 24 | table.backgroundColor = [UIColor lightGrayColor]; 25 | 26 | for(int i = 0; i < 14; i++) { 27 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 380, 60)]; 28 | label.text = @"CELL"; 29 | 30 | label.backgroundColor = (i % 2 == 0) ? [UIColor yellowColor] :[UIColor cyanColor]; 31 | [table addCell:label]; 32 | } 33 | 34 | 35 | [self.view addSubview:table]; 36 | } 37 | 38 | - (void)didReceiveMemoryWarning { 39 | [super didReceiveMemoryWarning]; 40 | // Dispose of any resources that can be recreated. 41 | } 42 | 43 | /* 44 | #pragma mark - Navigation 45 | 46 | // In a storyboard-based application, you will often want to do a little preparation before navigation 47 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 48 | // Get the new view controller using [segue destinationViewController]. 49 | // Pass the selected object to the new view controller. 50 | } 51 | */ 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /MagnetDynamicTable/DynamicTable.h: -------------------------------------------------------------------------------- 1 | // 2 | // DynamicTable.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 25/02/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DynamicTable : UIView 12 | 13 | @property (readonly) NSArray *columnWidths; 14 | 15 | @property (readonly) CGFloat cellWidth; 16 | 17 | @property (readonly) CGFloat cellHeight; 18 | 19 | @property (readonly) CGFloat cellMargin; 20 | 21 | @property (readonly) int rowIteratorIndex; 22 | 23 | @property UILabel *titleView; 24 | 25 | - (id)initWithFrame:(CGRect)frame cellWidth:(int)cellWidth cellMargin:(int)cellMargin title:(NSString *)title; 26 | 27 | - (id)initWithFrame:(CGRect)frame columnWidths:(NSArray *)columnWidths cellMargin:(int)cellMargin title:(NSString *)title; 28 | 29 | - (UIView *)cellForIndex:(int)cellIndex; 30 | 31 | - (void)addCell:(UIView *)cell; 32 | 33 | - (void)replaceCell:(UIView *)cell cellIndex:(int)cellIndex; 34 | 35 | - (void)removeCell:(int)cellIndex; 36 | 37 | - (void)updateSize; 38 | 39 | - (int)columnCount; 40 | 41 | - (BOOL)isRowCollapsed:(int)rowIndex; 42 | 43 | - (void)collapseRow:(int)rowIndex animate:(BOOL)animate; 44 | 45 | - (void)expandRow:(int)rowIndex animate:(BOOL)animate; 46 | 47 | - (void)toggleRow:(int)rowIndex animate:(BOOL)animate; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /MagnetDynamicTable/DynamicTable.m: -------------------------------------------------------------------------------- 1 | // 2 | // DynamicTable.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 25/02/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "DynamicTable.h" 10 | 11 | @interface DynamicTable() 12 | 13 | @property NSMutableArray *cells; 14 | 15 | @end 16 | 17 | 18 | @implementation DynamicTable 19 | 20 | - (id)initWithFrame:(CGRect)frame cellWidth:(int)cellWidth cellMargin:(int)cellMargin title:(NSString *)title 21 | { 22 | self = [super initWithFrame:frame]; 23 | if (self) { 24 | self->_cellWidth = cellWidth; 25 | self->_cellMargin = cellMargin; 26 | self.cells = [NSMutableArray new]; 27 | 28 | if(title) { 29 | self->_titleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 50)]; 30 | self.titleView.text = title; 31 | self.titleView.textColor = [UIColor whiteColor]; 32 | [self addSubview:self.titleView]; 33 | } 34 | } 35 | return self; 36 | } 37 | 38 | - (id)initWithFrame:(CGRect)frame columnWidths:(NSArray *)columnWidths cellMargin:(int)cellMargin title:(NSString *)title { 39 | if(self = [self initWithFrame:frame cellWidth:0 cellMargin:cellMargin title:title]) { 40 | self->_columnWidths = columnWidths; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (void)setCellWidth:(CGFloat)cellWidth { 47 | self->_cellWidth = cellWidth; 48 | [self repositionAllCells]; 49 | } 50 | 51 | - (void)setCellMargin:(CGFloat)cellMargin { 52 | self->_cellMargin = cellMargin; 53 | [self repositionAllCells]; 54 | } 55 | 56 | - (void)setColumnWidths:(NSArray *)columnWidths { 57 | self->_columnWidths = columnWidths; 58 | [self repositionAllCells]; 59 | } 60 | 61 | -(CGFloat)calculatedCellWidth { 62 | return self.cellWidth + self.cellMargin; 63 | } 64 | 65 | -(CGFloat)calculatedCellHeight { 66 | return self.cellHeight + self.cellMargin; 67 | } 68 | 69 | -(CGFloat)topMargin { 70 | if(self.titleView) 71 | return self.titleView.frame.size.height + self.cellMargin; 72 | else 73 | return 0; 74 | } 75 | 76 | -(int)rowCount { 77 | int rowCount = ceil((self.cells.count * [self calculatedCellWidth]) / self.frame.size.width); 78 | if(self.columnWidths != nil) 79 | rowCount = ceil(self.cells.count / self.columnWidths.count); 80 | if(rowCount == 0) 81 | rowCount = 1; 82 | return rowCount; 83 | } 84 | 85 | - (int)columnCount { 86 | if(self.columnWidths == nil) 87 | return floor(self.frame.size.width / [self calculatedCellWidth]); 88 | else 89 | return self.columnWidths.count; 90 | } 91 | 92 | 93 | - (CGFloat)totalHeight { 94 | CGFloat height = [self pointForCell:self.cells.count].y; 95 | int columnCount = [self columnCount]; 96 | int rowIndex = floor((self.cells.count - 1) / columnCount); 97 | if(self.cells.count % columnCount != 0) 98 | height += [self heightForRow:rowIndex] + self.cellMargin; 99 | return height; 100 | } 101 | 102 | - (CGFloat)heightForRow:(int)rowIndex { 103 | int columnCount = [self columnCount]; 104 | int currentHeight = 0; 105 | for(int i = rowIndex * columnCount; i < (rowIndex * columnCount) + columnCount && i < self.cells.count; i++) { 106 | UIView *cell = [self cellForIndex:i]; 107 | if(cell.frame.size.height > currentHeight) 108 | currentHeight = cell.frame.size.height; 109 | } 110 | 111 | return currentHeight; 112 | } 113 | 114 | - (CGPoint)pointForNewCell { 115 | return [self pointForCell:self.cells.count]; 116 | } 117 | 118 | - (CGPoint)pointForCell:(int)cellIndex { 119 | int columnCount = [self columnCount]; 120 | int rowIndex = floor(cellIndex / columnCount); 121 | int columnIndex = cellIndex % columnCount; 122 | 123 | CGFloat widthUnit = [self calculatedCellWidth]; 124 | 125 | if(self.columnWidths != nil) { 126 | widthUnit = 0; 127 | for(int i = 0; i < columnCount - 1; i++) { 128 | widthUnit += [(NSNumber *)[self.columnWidths objectAtIndex:i] floatValue]; 129 | widthUnit += self.cellMargin; 130 | } 131 | } 132 | 133 | CGFloat height = [self topMargin]; 134 | int currentRowIndex = 0; 135 | CGFloat currentRowHeight = 0; 136 | for(int j = 0; j < cellIndex; j++) { 137 | int iteratorRowIndex = floor(j / columnCount); 138 | UIView *cell = [self cellForIndex:j]; 139 | if(iteratorRowIndex != currentRowIndex) { 140 | currentRowIndex = iteratorRowIndex; 141 | height += currentRowHeight + self.cellMargin; 142 | currentRowHeight = cell.frame.size.height; 143 | } else { 144 | if(cell.frame.size.height > currentRowHeight) 145 | currentRowHeight = cell.frame.size.height; 146 | } 147 | } 148 | if(currentRowIndex != rowIndex) 149 | height += currentRowHeight + self.cellMargin; 150 | 151 | return CGPointMake(columnIndex * widthUnit, height); 152 | } 153 | 154 | 155 | 156 | -(void)updateSize { 157 | [self setFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, [self totalHeight])]; 158 | } 159 | 160 | - (void)willMoveToSuperview:(UIView *)newSuperview { 161 | [self updateSize]; 162 | } 163 | 164 | - (int)rowForCell:(int)cellIndex { 165 | return floor(cellIndex / [self columnCount]); 166 | } 167 | 168 | - (UIView *)cellForIndex:(int)cellIndex { 169 | return [self.cells objectAtIndex:cellIndex]; 170 | } 171 | 172 | - (void)replaceCell:(UIView *)cell cellIndex:(int)cellIndex { 173 | int columnIndex = cellIndex % [self columnCount]; 174 | if(cellIndex < self.cells.count) { 175 | UIView *subView = [self cellForIndex:cellIndex]; 176 | [self.cells removeObject:subView]; 177 | [subView removeFromSuperview]; 178 | } 179 | 180 | CGPoint point = [self pointForCell:cellIndex]; 181 | int width = self.columnWidths == nil ? self.cellWidth : [[self.columnWidths objectAtIndex:columnIndex] floatValue]; 182 | cell.frame = CGRectMake(point.x, point.y, width, cell.frame.size.height); 183 | [self addSubview:cell]; 184 | 185 | [self.cells insertObject:cell atIndex:cellIndex]; 186 | 187 | if(cellIndex < self.cells.count) 188 | [self repositionAllCells]; 189 | 190 | [self updateSize]; 191 | } 192 | 193 | - (void)repositionAllCells { 194 | for(int i = 0; i < self.cells.count; i++) { 195 | UIView *cell = [self cellForIndex:i]; 196 | CGPoint position = [self pointForCell:i]; 197 | cell.frame = CGRectMake(position.x, position.y, cell.frame.size.width, cell.frame.size.height); 198 | } 199 | } 200 | 201 | - (void)addCell:(UIView *)cell { 202 | [self replaceCell:cell cellIndex:self.cells.count]; 203 | } 204 | 205 | - (void)removeCell:(int)cellIndex { 206 | UIView *cell = [self cellForIndex:cellIndex]; 207 | [cell removeFromSuperview]; 208 | [self repositionAllCells]; 209 | [self updateSize]; 210 | } 211 | 212 | - (BOOL)isRowCollapsed:(int)rowIndex { 213 | UIView *view = [self cellForIndex:rowIndex]; 214 | return view.hidden; 215 | } 216 | 217 | - (void)collapseRow:(int)rowIndex animate:(BOOL)animate { 218 | if([self isRowCollapsed:rowIndex]) 219 | return; 220 | 221 | UIView *view = [self cellForIndex:rowIndex]; 222 | CGFloat height = view.frame.size.height + self.cellMargin; 223 | CGRect frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height); 224 | CGRect newFrame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height); 225 | 226 | CGFloat duration = animate ? 1.0 : 0; 227 | [UIView animateWithDuration:duration animations:^{ 228 | view.frame = newFrame; 229 | for(int i = rowIndex+1; i < self.cells.count; i++) { 230 | UIView *rowView = [self cellForIndex:i]; 231 | rowView.frame = CGRectMake(rowView.frame.origin.x, rowView.frame.origin.y - height, rowView.frame.size.width, rowView.frame.size.height); 232 | } 233 | 234 | } completion:^(BOOL finished) { 235 | view.frame = frame; 236 | [view setHidden:YES]; 237 | }]; 238 | } 239 | 240 | 241 | - (void)expandRow:(int)rowIndex animate:(BOOL)animate{ 242 | if(![self isRowCollapsed:rowIndex]) 243 | return; 244 | 245 | UIView *view = [self cellForIndex:rowIndex]; 246 | CGFloat height = view.frame.size.height + self.cellMargin; 247 | 248 | CGRect frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 0); 249 | CGRect newFrame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height); 250 | 251 | view.frame = frame; 252 | [view setHidden:NO]; 253 | 254 | CGFloat duration = animate ? 1.0 : 0; 255 | 256 | [UIView animateWithDuration:duration animations:^{ 257 | view.frame = newFrame; 258 | for(int i = rowIndex+1; i < self.cells.count; i++) { 259 | UIView *rowView = [self cellForIndex:i]; 260 | rowView.frame = CGRectMake(rowView.frame.origin.x, rowView.frame.origin.y + height, rowView.frame.size.width, rowView.frame.size.height); 261 | } 262 | 263 | } completion:^(BOOL finished) { 264 | }]; 265 | } 266 | 267 | 268 | - (void)toggleRow:(int)rowIndex animate:(BOOL)animate { 269 | UIView *view = [[self subviews] objectAtIndex:rowIndex]; 270 | if(view.isHidden) 271 | [self expandRow:rowIndex animate:animate]; 272 | else 273 | [self collapseRow:rowIndex animate:animate]; 274 | } 275 | 276 | 277 | - (void)setFrame:(CGRect)frame { 278 | [super setFrame:frame]; 279 | [self repositionAllCells]; 280 | } 281 | 282 | @end 283 | -------------------------------------------------------------------------------- /MagnetDynamicTable/Images.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 | } -------------------------------------------------------------------------------- /MagnetDynamicTable/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.macroismicro.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MagnetDynamicTable/InnerTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // InnerTableViewController.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 14/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface InnerTableViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MagnetDynamicTable/InnerTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // InnerTableViewController.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 14/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "InnerTableViewController.h" 10 | #import "DynamicTable.h" 11 | 12 | @interface InnerTableViewController () 13 | 14 | @property DynamicTable *table; 15 | 16 | @end 17 | 18 | @implementation InnerTableViewController 19 | 20 | - (void)viewDidLoad { 21 | 22 | UIScrollView *container = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; 23 | self.table = [[DynamicTable alloc] initWithFrame:CGRectMake(50, 50, 600, 100) cellWidth:580 cellMargin:5 title:nil]; 24 | 25 | self.table.backgroundColor = [UIColor lightGrayColor]; 26 | 27 | for(int i = 0; i < 30; i++) { 28 | 29 | DynamicTable *cell = [[DynamicTable alloc] initWithFrame:CGRectMake(0, 0, 580, 100) cellWidth:260 cellMargin:5 title:nil]; 30 | 31 | cell.backgroundColor = (i % 3 == 0) ? [UIColor cyanColor] : (i % 2 == 0) ? [UIColor yellowColor] : [UIColor whiteColor]; 32 | 33 | for(int j = 0; j < 6; j++) { 34 | if(j == 0) { 35 | UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 36 | [button setTitle:[NSString stringWithFormat:@"TOGGLE %i", i + 1] forState:UIControlStateNormal]; 37 | button.tag = i + 1; 38 | button.frame = CGRectMake(0, 0, 140, 40); 39 | [button addTarget:nil action:@selector(toggleRow:) forControlEvents:UIControlEventTouchUpInside]; 40 | [cell addCell:button]; 41 | } else { 42 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 260, 60)]; 43 | label.text = [NSString stringWithFormat:@"Cell %i", j]; 44 | label.backgroundColor = [UIColor lightTextColor]; 45 | [cell addCell:label]; 46 | } 47 | } 48 | 49 | [self.table addCell:cell]; 50 | } 51 | 52 | container.contentSize = self.table.frame.size; 53 | [container addSubview:self.table]; 54 | [self.view addSubview:container]; 55 | 56 | } 57 | 58 | - (void)toggleRow:(UIButton *)sender { 59 | [self.table toggleRow:sender.tag animate:YES]; 60 | } 61 | 62 | - (void)didReceiveMemoryWarning { 63 | [super didReceiveMemoryWarning]; 64 | // Dispose of any resources that can be recreated. 65 | } 66 | 67 | /* 68 | #pragma mark - Navigation 69 | 70 | // In a storyboard-based application, you will often want to do a little preparation before navigation 71 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 72 | // Get the new view controller using [segue destinationViewController]. 73 | // Pass the selected object to the new view controller. 74 | } 75 | */ 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /MagnetDynamicTable/TableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 25/02/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TableViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MagnetDynamicTable/TableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 25/02/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "TableViewController.h" 10 | #import "DynamicTable.h" 11 | 12 | @interface TableViewController () 13 | 14 | @property DynamicTable *table; 15 | 16 | @property UIButton *replaceButton; 17 | 18 | @property UITextField *replaceCell; 19 | 20 | @property int replacedCount; 21 | 22 | @end 23 | 24 | @implementation TableViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | // Do any additional setup after loading the view. 29 | 30 | self.table = [[DynamicTable alloc] initWithFrame:CGRectMake(50, 50, 600, 100) cellWidth:280 cellMargin:10 title:nil]; 31 | self.table.backgroundColor = [UIColor lightGrayColor]; 32 | 33 | UIView *subView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 30)]; 34 | subView1.backgroundColor = [UIColor redColor]; 35 | 36 | 37 | UIView *subView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 70)]; 38 | subView2.backgroundColor = [UIColor blueColor]; 39 | 40 | 41 | UIView *subView3 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 80)]; 42 | subView3.backgroundColor = [UIColor yellowColor]; 43 | 44 | UIView *subView4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 90)]; 45 | subView4.backgroundColor = [UIColor purpleColor]; 46 | 47 | UIView *subView5 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 110)]; 48 | subView5.backgroundColor = [UIColor cyanColor]; 49 | 50 | UIView *subView6 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 130)]; 51 | subView6.backgroundColor = [UIColor whiteColor]; 52 | 53 | 54 | [self.table addCell:subView1]; 55 | [self.table addCell:subView3]; 56 | [self.table addCell:subView2]; 57 | [self.table addCell:subView4]; 58 | [self.table addCell:subView5]; 59 | [self.table addCell:subView6]; 60 | 61 | [self.table updateSize]; 62 | 63 | [self.view addSubview:self.table]; 64 | 65 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 400, 100, 30)]; 66 | label.text = @"CELL NO:"; 67 | self.replaceCell = [[UITextField alloc] initWithFrame:CGRectMake(140, 400, 80, 30)]; 68 | self.replaceCell.backgroundColor = [UIColor lightGrayColor]; 69 | self.replaceButton = [UIButton buttonWithType:UIButtonTypeCustom]; 70 | self.replaceButton.backgroundColor = [UIColor blackColor]; 71 | [self.replaceButton setTitle:@"REPLACE CELL" forState:UIControlStateNormal]; 72 | self.replaceButton.frame = CGRectMake(230, 400, 150, 30); 73 | [self.replaceButton addTarget:nil action:@selector(replaceButtonClicked) forControlEvents:UIControlEventTouchUpInside]; 74 | 75 | 76 | [self.view addSubview:label]; 77 | [self.view addSubview:self.replaceCell]; 78 | [self.view addSubview:self.replaceButton]; 79 | 80 | self.replacedCount = 0; 81 | } 82 | 83 | - (void)replaceButtonClicked { 84 | int cellNo = [self.replaceCell.text intValue]; 85 | self.replacedCount++; 86 | 87 | UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 50)]; 88 | subView.backgroundColor = [UIColor greenColor]; 89 | 90 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 90, 20)]; 91 | label.text = [NSString stringWithFormat:@"replaced: %i", self.replacedCount]; 92 | [subView addSubview:label]; 93 | [self.table replaceCell:subView cellIndex:cellNo]; 94 | } 95 | 96 | - (void)didReceiveMemoryWarning { 97 | [super didReceiveMemoryWarning]; 98 | // Dispose of any resources that can be recreated. 99 | } 100 | 101 | /* 102 | #pragma mark - Navigation 103 | 104 | // In a storyboard-based application, you will often want to do a little preparation before navigation 105 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 106 | // Get the new view controller using [segue destinationViewController]. 107 | // Pass the selected object to the new view controller. 108 | } 109 | */ 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /MagnetDynamicTable/TabsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TabsViewController.h 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 14/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TabsViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MagnetDynamicTable/TabsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TabsViewController.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 14/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import "TabsViewController.h" 10 | #import "TableViewController.h" 11 | #import "InnerTableViewController.h" 12 | #import "ColumnsViewController.h" 13 | 14 | @interface TabsViewController () 15 | 16 | @property UITabBarController *tabController; 17 | 18 | @end 19 | 20 | @implementation TabsViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | self.view.backgroundColor = [UIColor whiteColor]; 26 | self.tabController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; 27 | [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:25.0f], NSFontAttributeName, nil] forState:UIControlStateNormal]; 28 | 29 | UITabBar.appearance.barStyle = UIBarStyleBlack; 30 | [UITabBar.appearance setItemWidth:200]; 31 | TableViewController *tableController = [[TableViewController alloc] initWithNibName:nil bundle:nil]; 32 | 33 | InnerTableViewController *innerController = [[InnerTableViewController alloc] initWithNibName:nil bundle:nil]; 34 | 35 | ColumnsViewController *columnsController = [[ColumnsViewController alloc] initWithNibName:nil bundle:nil]; 36 | 37 | tableController.tabBarItem.title = @"Add & Replace Cell"; 38 | columnsController.tabBarItem.title = @"Column widths"; 39 | innerController.tabBarItem.title = @"Table in table"; 40 | 41 | 42 | self.tabController.viewControllers = @[tableController, columnsController, innerController]; 43 | [self.view addSubview:self.tabController.view]; 44 | } 45 | 46 | - (void)didReceiveMemoryWarning { 47 | [super didReceiveMemoryWarning]; 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | /* 52 | #pragma mark - Navigation 53 | 54 | // In a storyboard-based application, you will often want to do a little preparation before navigation 55 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 56 | // Get the new view controller using [segue destinationViewController]. 57 | // Pass the selected object to the new view controller. 58 | } 59 | */ 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /MagnetDynamicTable/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MagnetDynamicTable 4 | // 5 | // Created by ufuk on 18/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MagnetDynamicTableTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.macroismicro.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MagnetDynamicTableTests/MagnetDynamicTableTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MagnetDynamicTableTests.m 3 | // MagnetDynamicTableTests 4 | // 5 | // Created by ufuk on 18/03/15. 6 | // Copyright (c) 2015 macroismicro. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MagnetDynamicTableTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation MagnetDynamicTableTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MagnetDynamicTable is a simple replacement for UITableView. Basic idea is to provide HTML table like functionality on IOS. Instead of using delegate events as with UITableView, you'll add, replace and remove cells directly after initialization or at runtime. 2 | 3 | A table cell is simply an instance of UIView. Cell positions are set as you add them to the table, so you won't need to worry about that. You can also replace and remove cells and all cell positions will be automatically updated. 4 | 5 | Creating a table is simple: 6 | 7 | DynamicTable *table = [[DynamicTable alloc] initWithFrame:CGRectMake(0, 0, 500, 100) cellWidth:260 cellMargin:5 title:nil]; 8 | 9 | Height is unimportant as it will be automatically set to total row height. 10 | 11 | Adding a cell: 12 | 13 | UIView *view = [UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] 14 | [table addCell:view]; 15 | 16 | For table cells, position given at the initialization is unimportant as it will be reset after calling addCell method. 17 | 18 | You can use a table instance as another table's cell. In that case, height of parent table will be updated as the child table's size changes: 19 | 20 | [parentTable updateSize]; 21 | 22 | You can also expand and collapse rows with or without animation: 23 | 24 | [table expandRow:rowOrCellIndex animate:YES]; 25 | [table collapseRow:rowOrCellIndex animate:YES]; 26 | [table toggleRow:rowOrCellIndex animate:YES]; 27 | --------------------------------------------------------------------------------