├── README.md ├── ThreeLevelCellDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── WM.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── WM.xcuserdatad │ └── xcschemes │ ├── ThreeLevelCellDemo.xcscheme │ └── xcschememanagement.plist └── ThreeLevelCellDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── DemoCell.h ├── DemoCell.m ├── DemoModel.h ├── DemoModel.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # ThreeLevelCellDemo 2 | 自定义UITableView,实现cell的三级分组展开,收起 3 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 97E32DA41CFC9CBD0066A1D9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E32DA31CFC9CBD0066A1D9 /* main.m */; }; 11 | 97E32DA71CFC9CBD0066A1D9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E32DA61CFC9CBD0066A1D9 /* AppDelegate.m */; }; 12 | 97E32DAA1CFC9CBD0066A1D9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E32DA91CFC9CBD0066A1D9 /* ViewController.m */; }; 13 | 97E32DAD1CFC9CBD0066A1D9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97E32DAB1CFC9CBD0066A1D9 /* Main.storyboard */; }; 14 | 97E32DAF1CFC9CBD0066A1D9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97E32DAE1CFC9CBD0066A1D9 /* Assets.xcassets */; }; 15 | 97E32DB21CFC9CBD0066A1D9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97E32DB01CFC9CBD0066A1D9 /* LaunchScreen.storyboard */; }; 16 | 97E32DBD1CFC9CDC0066A1D9 /* DemoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E32DBA1CFC9CDC0066A1D9 /* DemoCell.m */; }; 17 | 97E32DBE1CFC9CDC0066A1D9 /* DemoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E32DBC1CFC9CDC0066A1D9 /* DemoModel.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 97E32D9F1CFC9CBD0066A1D9 /* ThreeLevelCellDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThreeLevelCellDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 97E32DA31CFC9CBD0066A1D9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 23 | 97E32DA51CFC9CBD0066A1D9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | 97E32DA61CFC9CBD0066A1D9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | 97E32DA81CFC9CBD0066A1D9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 26 | 97E32DA91CFC9CBD0066A1D9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 27 | 97E32DAC1CFC9CBD0066A1D9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | 97E32DAE1CFC9CBD0066A1D9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 97E32DB11CFC9CBD0066A1D9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | 97E32DB31CFC9CBD0066A1D9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 97E32DB91CFC9CDC0066A1D9 /* DemoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoCell.h; sourceTree = ""; }; 32 | 97E32DBA1CFC9CDC0066A1D9 /* DemoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoCell.m; sourceTree = ""; }; 33 | 97E32DBB1CFC9CDC0066A1D9 /* DemoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoModel.h; sourceTree = ""; }; 34 | 97E32DBC1CFC9CDC0066A1D9 /* DemoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoModel.m; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 97E32D9C1CFC9CBD0066A1D9 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 97E32D961CFC9CBD0066A1D9 = { 49 | isa = PBXGroup; 50 | children = ( 51 | 97E32DA11CFC9CBD0066A1D9 /* ThreeLevelCellDemo */, 52 | 97E32DA01CFC9CBD0066A1D9 /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 97E32DA01CFC9CBD0066A1D9 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 97E32D9F1CFC9CBD0066A1D9 /* ThreeLevelCellDemo.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 97E32DA11CFC9CBD0066A1D9 /* ThreeLevelCellDemo */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 97E32DA51CFC9CBD0066A1D9 /* AppDelegate.h */, 68 | 97E32DA61CFC9CBD0066A1D9 /* AppDelegate.m */, 69 | 97E32DA81CFC9CBD0066A1D9 /* ViewController.h */, 70 | 97E32DA91CFC9CBD0066A1D9 /* ViewController.m */, 71 | 97E32DB91CFC9CDC0066A1D9 /* DemoCell.h */, 72 | 97E32DBA1CFC9CDC0066A1D9 /* DemoCell.m */, 73 | 97E32DBB1CFC9CDC0066A1D9 /* DemoModel.h */, 74 | 97E32DBC1CFC9CDC0066A1D9 /* DemoModel.m */, 75 | 97E32DAB1CFC9CBD0066A1D9 /* Main.storyboard */, 76 | 97E32DAE1CFC9CBD0066A1D9 /* Assets.xcassets */, 77 | 97E32DB01CFC9CBD0066A1D9 /* LaunchScreen.storyboard */, 78 | 97E32DB31CFC9CBD0066A1D9 /* Info.plist */, 79 | 97E32DA21CFC9CBD0066A1D9 /* Supporting Files */, 80 | ); 81 | path = ThreeLevelCellDemo; 82 | sourceTree = ""; 83 | }; 84 | 97E32DA21CFC9CBD0066A1D9 /* Supporting Files */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 97E32DA31CFC9CBD0066A1D9 /* main.m */, 88 | ); 89 | name = "Supporting Files"; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | 97E32D9E1CFC9CBD0066A1D9 /* ThreeLevelCellDemo */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = 97E32DB61CFC9CBD0066A1D9 /* Build configuration list for PBXNativeTarget "ThreeLevelCellDemo" */; 98 | buildPhases = ( 99 | 97E32D9B1CFC9CBD0066A1D9 /* Sources */, 100 | 97E32D9C1CFC9CBD0066A1D9 /* Frameworks */, 101 | 97E32D9D1CFC9CBD0066A1D9 /* Resources */, 102 | ); 103 | buildRules = ( 104 | ); 105 | dependencies = ( 106 | ); 107 | name = ThreeLevelCellDemo; 108 | productName = ThreeLevelCellDemo; 109 | productReference = 97E32D9F1CFC9CBD0066A1D9 /* ThreeLevelCellDemo.app */; 110 | productType = "com.apple.product-type.application"; 111 | }; 112 | /* End PBXNativeTarget section */ 113 | 114 | /* Begin PBXProject section */ 115 | 97E32D971CFC9CBD0066A1D9 /* Project object */ = { 116 | isa = PBXProject; 117 | attributes = { 118 | LastUpgradeCheck = 0720; 119 | ORGANIZATIONNAME = Stronger_WM; 120 | TargetAttributes = { 121 | 97E32D9E1CFC9CBD0066A1D9 = { 122 | CreatedOnToolsVersion = 7.2.1; 123 | }; 124 | }; 125 | }; 126 | buildConfigurationList = 97E32D9A1CFC9CBD0066A1D9 /* Build configuration list for PBXProject "ThreeLevelCellDemo" */; 127 | compatibilityVersion = "Xcode 3.2"; 128 | developmentRegion = English; 129 | hasScannedForEncodings = 0; 130 | knownRegions = ( 131 | en, 132 | Base, 133 | ); 134 | mainGroup = 97E32D961CFC9CBD0066A1D9; 135 | productRefGroup = 97E32DA01CFC9CBD0066A1D9 /* Products */; 136 | projectDirPath = ""; 137 | projectRoot = ""; 138 | targets = ( 139 | 97E32D9E1CFC9CBD0066A1D9 /* ThreeLevelCellDemo */, 140 | ); 141 | }; 142 | /* End PBXProject section */ 143 | 144 | /* Begin PBXResourcesBuildPhase section */ 145 | 97E32D9D1CFC9CBD0066A1D9 /* Resources */ = { 146 | isa = PBXResourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 97E32DB21CFC9CBD0066A1D9 /* LaunchScreen.storyboard in Resources */, 150 | 97E32DAF1CFC9CBD0066A1D9 /* Assets.xcassets in Resources */, 151 | 97E32DAD1CFC9CBD0066A1D9 /* Main.storyboard in Resources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXResourcesBuildPhase section */ 156 | 157 | /* Begin PBXSourcesBuildPhase section */ 158 | 97E32D9B1CFC9CBD0066A1D9 /* Sources */ = { 159 | isa = PBXSourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97E32DAA1CFC9CBD0066A1D9 /* ViewController.m in Sources */, 163 | 97E32DA71CFC9CBD0066A1D9 /* AppDelegate.m in Sources */, 164 | 97E32DBD1CFC9CDC0066A1D9 /* DemoCell.m in Sources */, 165 | 97E32DBE1CFC9CDC0066A1D9 /* DemoModel.m in Sources */, 166 | 97E32DA41CFC9CBD0066A1D9 /* main.m in Sources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXSourcesBuildPhase section */ 171 | 172 | /* Begin PBXVariantGroup section */ 173 | 97E32DAB1CFC9CBD0066A1D9 /* Main.storyboard */ = { 174 | isa = PBXVariantGroup; 175 | children = ( 176 | 97E32DAC1CFC9CBD0066A1D9 /* Base */, 177 | ); 178 | name = Main.storyboard; 179 | sourceTree = ""; 180 | }; 181 | 97E32DB01CFC9CBD0066A1D9 /* LaunchScreen.storyboard */ = { 182 | isa = PBXVariantGroup; 183 | children = ( 184 | 97E32DB11CFC9CBD0066A1D9 /* Base */, 185 | ); 186 | name = LaunchScreen.storyboard; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXVariantGroup section */ 190 | 191 | /* Begin XCBuildConfiguration section */ 192 | 97E32DB41CFC9CBD0066A1D9 /* Debug */ = { 193 | isa = XCBuildConfiguration; 194 | buildSettings = { 195 | ALWAYS_SEARCH_USER_PATHS = NO; 196 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 197 | CLANG_CXX_LIBRARY = "libc++"; 198 | CLANG_ENABLE_MODULES = YES; 199 | CLANG_ENABLE_OBJC_ARC = YES; 200 | CLANG_WARN_BOOL_CONVERSION = YES; 201 | CLANG_WARN_CONSTANT_CONVERSION = YES; 202 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INT_CONVERSION = YES; 206 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 207 | CLANG_WARN_UNREACHABLE_CODE = YES; 208 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 209 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 210 | COPY_PHASE_STRIP = NO; 211 | DEBUG_INFORMATION_FORMAT = dwarf; 212 | ENABLE_STRICT_OBJC_MSGSEND = YES; 213 | ENABLE_TESTABILITY = YES; 214 | GCC_C_LANGUAGE_STANDARD = gnu99; 215 | GCC_DYNAMIC_NO_PIC = NO; 216 | GCC_NO_COMMON_BLOCKS = YES; 217 | GCC_OPTIMIZATION_LEVEL = 0; 218 | GCC_PREPROCESSOR_DEFINITIONS = ( 219 | "DEBUG=1", 220 | "$(inherited)", 221 | ); 222 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 223 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 224 | GCC_WARN_UNDECLARED_SELECTOR = YES; 225 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 226 | GCC_WARN_UNUSED_FUNCTION = YES; 227 | GCC_WARN_UNUSED_VARIABLE = YES; 228 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 229 | MTL_ENABLE_DEBUG_INFO = YES; 230 | ONLY_ACTIVE_ARCH = YES; 231 | SDKROOT = iphoneos; 232 | TARGETED_DEVICE_FAMILY = "1,2"; 233 | }; 234 | name = Debug; 235 | }; 236 | 97E32DB51CFC9CBD0066A1D9 /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 247 | CLANG_WARN_EMPTY_BODY = YES; 248 | CLANG_WARN_ENUM_CONVERSION = YES; 249 | CLANG_WARN_INT_CONVERSION = YES; 250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 251 | CLANG_WARN_UNREACHABLE_CODE = YES; 252 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 253 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 254 | COPY_PHASE_STRIP = NO; 255 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 256 | ENABLE_NS_ASSERTIONS = NO; 257 | ENABLE_STRICT_OBJC_MSGSEND = YES; 258 | GCC_C_LANGUAGE_STANDARD = gnu99; 259 | GCC_NO_COMMON_BLOCKS = YES; 260 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 261 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 262 | GCC_WARN_UNDECLARED_SELECTOR = YES; 263 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 264 | GCC_WARN_UNUSED_FUNCTION = YES; 265 | GCC_WARN_UNUSED_VARIABLE = YES; 266 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 267 | MTL_ENABLE_DEBUG_INFO = NO; 268 | SDKROOT = iphoneos; 269 | TARGETED_DEVICE_FAMILY = "1,2"; 270 | VALIDATE_PRODUCT = YES; 271 | }; 272 | name = Release; 273 | }; 274 | 97E32DB71CFC9CBD0066A1D9 /* Debug */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 278 | INFOPLIST_FILE = ThreeLevelCellDemo/Info.plist; 279 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 280 | PRODUCT_BUNDLE_IDENTIFIER = WAY.WeAreYoung.ThreeLevelCellDemo; 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | }; 283 | name = Debug; 284 | }; 285 | 97E32DB81CFC9CBD0066A1D9 /* Release */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | INFOPLIST_FILE = ThreeLevelCellDemo/Info.plist; 290 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 291 | PRODUCT_BUNDLE_IDENTIFIER = WAY.WeAreYoung.ThreeLevelCellDemo; 292 | PRODUCT_NAME = "$(TARGET_NAME)"; 293 | }; 294 | name = Release; 295 | }; 296 | /* End XCBuildConfiguration section */ 297 | 298 | /* Begin XCConfigurationList section */ 299 | 97E32D9A1CFC9CBD0066A1D9 /* Build configuration list for PBXProject "ThreeLevelCellDemo" */ = { 300 | isa = XCConfigurationList; 301 | buildConfigurations = ( 302 | 97E32DB41CFC9CBD0066A1D9 /* Debug */, 303 | 97E32DB51CFC9CBD0066A1D9 /* Release */, 304 | ); 305 | defaultConfigurationIsVisible = 0; 306 | defaultConfigurationName = Release; 307 | }; 308 | 97E32DB61CFC9CBD0066A1D9 /* Build configuration list for PBXNativeTarget "ThreeLevelCellDemo" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 97E32DB71CFC9CBD0066A1D9 /* Debug */, 312 | 97E32DB81CFC9CBD0066A1D9 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | }; 316 | /* End XCConfigurationList section */ 317 | }; 318 | rootObject = 97E32D971CFC9CBD0066A1D9 /* Project object */; 319 | } 320 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo.xcodeproj/project.xcworkspace/xcuserdata/WM.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongerWM/ThreeLevelCellDemo/f5db632311763c29ad0adca452860c3c7332645d/ThreeLevelCellDemo.xcodeproj/project.xcworkspace/xcuserdata/WM.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ThreeLevelCellDemo.xcodeproj/xcuserdata/WM.xcuserdatad/xcschemes/ThreeLevelCellDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo.xcodeproj/xcuserdata/WM.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ThreeLevelCellDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 97E32D9E1CFC9CBD0066A1D9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ThreeLevelCellDemo 4 | // 5 | // Created by Stronger_WM on 16/5/31. 6 | // Copyright © 2016年 Stronger_WM. 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 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ThreeLevelCellDemo 4 | // 5 | // Created by Stronger_WM on 16/5/31. 6 | // Copyright © 2016年 Stronger_WM. 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 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/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 | } -------------------------------------------------------------------------------- /ThreeLevelCellDemo/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 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/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 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/DemoCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoCell.h 3 | // MultiGroupDemo 4 | // 5 | // Created by Stronger_WM on 16/5/28. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DemoModel.h" 11 | 12 | @interface DemoCell : UITableViewCell 13 | 14 | - (void)updateCellWithModel:(DemoModel *)model; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/DemoCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoCell.m 3 | // MultiGroupDemo 4 | // 5 | // Created by Stronger_WM on 16/5/28. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import "DemoCell.h" 10 | 11 | 12 | @implementation DemoCell 13 | 14 | - (void)updateCellWithModel:(DemoModel *)model 15 | { 16 | //如果是一级cell 17 | if (model.second_index == 0 && model.third_index == 0) { 18 | self.textLabel.text = [NSString stringWithFormat:@"%ld.%ld.%ld",model.first_index,model.second_index,model.third_index]; 19 | return; 20 | } 21 | 22 | //如果是二级cell 23 | if (model.third_index == 0) { 24 | self.textLabel.text = [NSString stringWithFormat:@" %ld.%ld.%ld",model.first_index,model.second_index,model.third_index]; 25 | return; 26 | } 27 | 28 | //如果是三级cell 29 | self.textLabel.text = [NSString stringWithFormat:@" %ld.%ld.%ld",model.first_index,model.second_index,model.third_index]; 30 | } 31 | 32 | - (void)awakeFromNib { 33 | // Initialization code 34 | } 35 | 36 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 37 | [super setSelected:selected animated:animated]; 38 | 39 | // Configure the view for the selected state 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/DemoModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoModel.h 3 | // MultiGroupDemo 4 | // 5 | // Created by Stronger_WM on 16/5/28. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DemoModel : NSObject 12 | 13 | @property (nonatomic ,assign) NSInteger first_index; 14 | @property (nonatomic ,assign) NSInteger second_index; 15 | @property (nonatomic ,assign) NSInteger third_index; 16 | @property (nonatomic ,assign) BOOL is_show; //是否显示 17 | @property (nonatomic ,assign) BOOL is_open; //是否打开 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/DemoModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoModel.m 3 | // MultiGroupDemo 4 | // 5 | // Created by Stronger_WM on 16/5/28. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import "DemoModel.h" 10 | 11 | @implementation DemoModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/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 | 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 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ThreeLevelCellDemo 4 | // 5 | // Created by Stronger_WM on 16/5/31. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ThreeLevelCellDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MultiGroupDemo 4 | // 5 | // Created by Stronger_WM on 16/5/28. 6 | // Copyright © 2016年 Stronger_WM. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DemoModel.h" 11 | #import "DemoCell.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (nonatomic ,strong) UITableView *tableView; 16 | @property (nonatomic ,strong) NSMutableArray *dataArr; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | #pragma mark - data update 23 | - (void)clickCellAtIndexPath:(NSIndexPath *)indexPath 24 | { 25 | DemoModel *current_model = _dataArr[indexPath.row]; 26 | //如果点击的是一级cell 27 | if (current_model.second_index == 0 && current_model.third_index == 0) { 28 | //如果该一级cell是展开的 29 | if (current_model.is_open) { 30 | for (DemoModel *model in _dataArr) { 31 | BOOL is_belong = model.first_index == current_model.first_index; //是否在当前分组 32 | BOOL is_current = model.second_index == 0; //是否是一级cell 33 | //如果在当前分组下,并且不是一级cell,则全部隐藏,关闭 34 | if (is_belong && !is_current) { 35 | model.is_open = NO; 36 | model.is_show = NO; 37 | } 38 | else 39 | { 40 | //其他一级cell,不操作 41 | } 42 | } 43 | //关闭该一级cell 44 | current_model.is_open = NO; 45 | [_tableView reloadData]; 46 | return; 47 | } 48 | //如果该一级cell是关闭的 49 | else 50 | { 51 | for (DemoModel *model in _dataArr) { 52 | BOOL is_belong = model.first_index == current_model.first_index; //是否在当前分组 53 | BOOL is_current = model.second_index == 0; //是否是一级cell 54 | //如果在当前分组下,并且不是一级cell,则二级cell显示,三级cell不操作 55 | if (is_belong && !is_current) { 56 | //如果是二级cell 57 | if (model.third_index == 0) { 58 | model.is_show = YES; 59 | } 60 | else 61 | { 62 | //三级cell,不操作 63 | } 64 | } 65 | else 66 | { 67 | //其他一级cell,不操作 68 | } 69 | } 70 | //打开该一级cell 71 | current_model.is_open = YES; 72 | [_tableView reloadData]; 73 | return; 74 | } 75 | } 76 | 77 | //如果点击的是二级cell 78 | if (current_model.third_index == 0) { 79 | //如果该二级cell是展开的 80 | if (current_model.is_open) { 81 | for (DemoModel *model in _dataArr) { 82 | BOOL is_belong = model.second_index == current_model.second_index && model.first_index == current_model.first_index; //是否在当前分组 83 | BOOL is_current = model.third_index == 0; //是否是二级cell 84 | //如果在当前分组下,并且不是二级cell,则全部隐藏 85 | if (is_belong && !is_current) { 86 | model.is_show = NO; 87 | } 88 | else 89 | { 90 | //其他二级cell,不操作 91 | } 92 | } 93 | //关闭该二级cell 94 | current_model.is_open = NO; 95 | [_tableView reloadData]; 96 | return; 97 | } 98 | //如果该二级cell是关闭的 99 | else 100 | { 101 | for (DemoModel *model in _dataArr) { 102 | BOOL is_belong = model.second_index == current_model.second_index && model.first_index == current_model.first_index; //是否在当前分组 103 | BOOL is_current = model.third_index == 0; //是否是二级cell 104 | //如果在当前分组下,并且不是二级cell,则全部显示 105 | if (is_belong && !is_current) { 106 | model.is_show = YES; 107 | } 108 | else 109 | { 110 | //其他二级cell,不操作 111 | } 112 | } 113 | //打开该二级cell 114 | current_model.is_open = YES; 115 | [_tableView reloadData]; 116 | return; 117 | } 118 | } 119 | 120 | //如果点击的是三级cell 121 | NSLog(@"点击了三级cell"); 122 | } 123 | 124 | #pragma mark - lifecycle 125 | - (void)viewDidLoad { 126 | [super viewDidLoad]; 127 | // Do any additional setup after loading the view, typically from a nib. 128 | 129 | //模拟数据 130 | _dataArr = [NSMutableArray array]; 131 | 132 | NSArray *first_indexs = @[@1,@2]; 133 | NSArray *second_indexs = @[@0,@1]; 134 | NSArray *third_indexs = @[@0,@1,@2]; 135 | 136 | for (int i=0; i 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 | --------------------------------------------------------------------------------