├── README.md ├── image └── 111.gif ├── tableview联动.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── zuozhongfei.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── zuozhongfei.xcuserdatad │ └── xcschemes │ ├── tableview联动.xcscheme │ └── xcschememanagement.plist └── tableview联动 ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # tableView-combine 2 | tableView二级联动 3 | 4 | ![image](https://github.com/ZZFCode/tableView-combine/blob/master/image/111.gif) 5 | 6 | -------------------------------------------------------------------------------- /image/111.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZZFCode/tableView-combine/27bc63dc24d36d32764ba996ff3da8d52fdb2090/image/111.gif -------------------------------------------------------------------------------- /tableview联动.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9553B0201D000553000EBDBA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9553B01F1D000553000EBDBA /* main.m */; }; 11 | 9553B0231D000553000EBDBA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9553B0221D000553000EBDBA /* AppDelegate.m */; }; 12 | 9553B0261D000553000EBDBA /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9553B0251D000553000EBDBA /* ViewController.m */; }; 13 | 9553B0291D000553000EBDBA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9553B0271D000553000EBDBA /* Main.storyboard */; }; 14 | 9553B02B1D000553000EBDBA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9553B02A1D000553000EBDBA /* Assets.xcassets */; }; 15 | 9553B02E1D000553000EBDBA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9553B02C1D000553000EBDBA /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 9553B01B1D000553000EBDBA /* tableview联动.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "tableview联动.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 9553B01F1D000553000EBDBA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 21 | 9553B0211D000553000EBDBA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 22 | 9553B0221D000553000EBDBA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 23 | 9553B0241D000553000EBDBA /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 24 | 9553B0251D000553000EBDBA /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 25 | 9553B0281D000553000EBDBA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 9553B02A1D000553000EBDBA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 9553B02D1D000553000EBDBA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 9553B02F1D000553000EBDBA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 9553B0181D000553000EBDBA /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 9553B0121D000553000EBDBA = { 43 | isa = PBXGroup; 44 | children = ( 45 | 9553B01D1D000553000EBDBA /* tableview联动 */, 46 | 9553B01C1D000553000EBDBA /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 9553B01C1D000553000EBDBA /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 9553B01B1D000553000EBDBA /* tableview联动.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 9553B01D1D000553000EBDBA /* tableview联动 */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 9553B0211D000553000EBDBA /* AppDelegate.h */, 62 | 9553B0221D000553000EBDBA /* AppDelegate.m */, 63 | 9553B0241D000553000EBDBA /* ViewController.h */, 64 | 9553B0251D000553000EBDBA /* ViewController.m */, 65 | 9553B0271D000553000EBDBA /* Main.storyboard */, 66 | 9553B02A1D000553000EBDBA /* Assets.xcassets */, 67 | 9553B02C1D000553000EBDBA /* LaunchScreen.storyboard */, 68 | 9553B02F1D000553000EBDBA /* Info.plist */, 69 | 9553B01E1D000553000EBDBA /* Supporting Files */, 70 | ); 71 | path = "tableview联动"; 72 | sourceTree = ""; 73 | }; 74 | 9553B01E1D000553000EBDBA /* Supporting Files */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 9553B01F1D000553000EBDBA /* main.m */, 78 | ); 79 | name = "Supporting Files"; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 9553B01A1D000553000EBDBA /* tableview联动 */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 9553B0321D000553000EBDBA /* Build configuration list for PBXNativeTarget "tableview联动" */; 88 | buildPhases = ( 89 | 9553B0171D000553000EBDBA /* Sources */, 90 | 9553B0181D000553000EBDBA /* Frameworks */, 91 | 9553B0191D000553000EBDBA /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = "tableview联动"; 98 | productName = "tableview联动"; 99 | productReference = 9553B01B1D000553000EBDBA /* tableview联动.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 9553B0131D000553000EBDBA /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 0730; 109 | ORGANIZATIONNAME = zzf.con; 110 | TargetAttributes = { 111 | 9553B01A1D000553000EBDBA = { 112 | CreatedOnToolsVersion = 7.3; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 9553B0161D000553000EBDBA /* Build configuration list for PBXProject "tableview联动" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 9553B0121D000553000EBDBA; 125 | productRefGroup = 9553B01C1D000553000EBDBA /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 9553B01A1D000553000EBDBA /* tableview联动 */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 9553B0191D000553000EBDBA /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 9553B02E1D000553000EBDBA /* LaunchScreen.storyboard in Resources */, 140 | 9553B02B1D000553000EBDBA /* Assets.xcassets in Resources */, 141 | 9553B0291D000553000EBDBA /* Main.storyboard in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 9553B0171D000553000EBDBA /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 9553B0261D000553000EBDBA /* ViewController.m in Sources */, 153 | 9553B0231D000553000EBDBA /* AppDelegate.m in Sources */, 154 | 9553B0201D000553000EBDBA /* main.m in Sources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXSourcesBuildPhase section */ 159 | 160 | /* Begin PBXVariantGroup section */ 161 | 9553B0271D000553000EBDBA /* Main.storyboard */ = { 162 | isa = PBXVariantGroup; 163 | children = ( 164 | 9553B0281D000553000EBDBA /* Base */, 165 | ); 166 | name = Main.storyboard; 167 | sourceTree = ""; 168 | }; 169 | 9553B02C1D000553000EBDBA /* LaunchScreen.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 9553B02D1D000553000EBDBA /* Base */, 173 | ); 174 | name = LaunchScreen.storyboard; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXVariantGroup section */ 178 | 179 | /* Begin XCBuildConfiguration section */ 180 | 9553B0301D000553000EBDBA /* Debug */ = { 181 | isa = XCBuildConfiguration; 182 | buildSettings = { 183 | ALWAYS_SEARCH_USER_PATHS = NO; 184 | CLANG_ANALYZER_NONNULL = YES; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_EMPTY_BODY = YES; 193 | CLANG_WARN_ENUM_CONVERSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_UNREACHABLE_CODE = YES; 197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 198 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 199 | COPY_PHASE_STRIP = NO; 200 | DEBUG_INFORMATION_FORMAT = dwarf; 201 | ENABLE_STRICT_OBJC_MSGSEND = YES; 202 | ENABLE_TESTABILITY = YES; 203 | GCC_C_LANGUAGE_STANDARD = gnu99; 204 | GCC_DYNAMIC_NO_PIC = NO; 205 | GCC_NO_COMMON_BLOCKS = YES; 206 | GCC_OPTIMIZATION_LEVEL = 0; 207 | GCC_PREPROCESSOR_DEFINITIONS = ( 208 | "DEBUG=1", 209 | "$(inherited)", 210 | ); 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 218 | MTL_ENABLE_DEBUG_INFO = YES; 219 | ONLY_ACTIVE_ARCH = YES; 220 | SDKROOT = iphoneos; 221 | TARGETED_DEVICE_FAMILY = "1,2"; 222 | }; 223 | name = Debug; 224 | }; 225 | 9553B0311D000553000EBDBA /* Release */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ALWAYS_SEARCH_USER_PATHS = NO; 229 | CLANG_ANALYZER_NONNULL = YES; 230 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 231 | CLANG_CXX_LIBRARY = "libc++"; 232 | CLANG_ENABLE_MODULES = YES; 233 | CLANG_ENABLE_OBJC_ARC = YES; 234 | CLANG_WARN_BOOL_CONVERSION = YES; 235 | CLANG_WARN_CONSTANT_CONVERSION = YES; 236 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 237 | CLANG_WARN_EMPTY_BODY = YES; 238 | CLANG_WARN_ENUM_CONVERSION = YES; 239 | CLANG_WARN_INT_CONVERSION = YES; 240 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 246 | ENABLE_NS_ASSERTIONS = NO; 247 | ENABLE_STRICT_OBJC_MSGSEND = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_NO_COMMON_BLOCKS = YES; 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 257 | MTL_ENABLE_DEBUG_INFO = NO; 258 | SDKROOT = iphoneos; 259 | TARGETED_DEVICE_FAMILY = "1,2"; 260 | VALIDATE_PRODUCT = YES; 261 | }; 262 | name = Release; 263 | }; 264 | 9553B0331D000553000EBDBA /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 268 | INFOPLIST_FILE = "tableview联动/Info.plist"; 269 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 270 | PRODUCT_BUNDLE_IDENTIFIER = "com.zzf.tableview--"; 271 | PRODUCT_NAME = "$(TARGET_NAME)"; 272 | }; 273 | name = Debug; 274 | }; 275 | 9553B0341D000553000EBDBA /* Release */ = { 276 | isa = XCBuildConfiguration; 277 | buildSettings = { 278 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 279 | INFOPLIST_FILE = "tableview联动/Info.plist"; 280 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 281 | PRODUCT_BUNDLE_IDENTIFIER = "com.zzf.tableview--"; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | }; 284 | name = Release; 285 | }; 286 | /* End XCBuildConfiguration section */ 287 | 288 | /* Begin XCConfigurationList section */ 289 | 9553B0161D000553000EBDBA /* Build configuration list for PBXProject "tableview联动" */ = { 290 | isa = XCConfigurationList; 291 | buildConfigurations = ( 292 | 9553B0301D000553000EBDBA /* Debug */, 293 | 9553B0311D000553000EBDBA /* Release */, 294 | ); 295 | defaultConfigurationIsVisible = 0; 296 | defaultConfigurationName = Release; 297 | }; 298 | 9553B0321D000553000EBDBA /* Build configuration list for PBXNativeTarget "tableview联动" */ = { 299 | isa = XCConfigurationList; 300 | buildConfigurations = ( 301 | 9553B0331D000553000EBDBA /* Debug */, 302 | 9553B0341D000553000EBDBA /* Release */, 303 | ); 304 | defaultConfigurationIsVisible = 0; 305 | }; 306 | /* End XCConfigurationList section */ 307 | }; 308 | rootObject = 9553B0131D000553000EBDBA /* Project object */; 309 | } 310 | -------------------------------------------------------------------------------- /tableview联动.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tableview联动.xcodeproj/project.xcworkspace/xcuserdata/zuozhongfei.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZZFCode/tableView-combine/27bc63dc24d36d32764ba996ff3da8d52fdb2090/tableview联动.xcodeproj/project.xcworkspace/xcuserdata/zuozhongfei.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /tableview联动.xcodeproj/xcuserdata/zuozhongfei.xcuserdatad/xcschemes/tableview联动.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 | -------------------------------------------------------------------------------- /tableview联动.xcodeproj/xcuserdata/zuozhongfei.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | tableview联动.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 9553B01A1D000553000EBDBA 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tableview联动/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // tableview联动 4 | // 5 | // Created by 左忠飞 on 16/6/2. 6 | // Copyright © 2016年 zzf.con. 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 | -------------------------------------------------------------------------------- /tableview联动/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // tableview联动 4 | // 5 | // Created by 左忠飞 on 16/6/2. 6 | // Copyright © 2016年 zzf.con. 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 | -------------------------------------------------------------------------------- /tableview联动/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 | } -------------------------------------------------------------------------------- /tableview联动/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 | -------------------------------------------------------------------------------- /tableview联动/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 | -------------------------------------------------------------------------------- /tableview联动/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 | -------------------------------------------------------------------------------- /tableview联动/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // tableview联动 4 | // 5 | // Created by 左忠飞 on 16/6/2. 6 | // Copyright © 2016年 zzf.con. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | { 14 | NSArray *_dataArray; 15 | BOOL _isRelate; 16 | } 17 | 18 | @property(nonatomic,strong)UITableView *leftTableview; 19 | @property(nonatomic,strong)UITableView *rightTableview; 20 | @property(nonatomic,strong)UIView *lineView; 21 | 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /tableview联动/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // tableview联动 4 | // 5 | // Created by 左忠飞 on 16/6/2. 6 | // Copyright © 2016年 zzf.con. All rights reserved. 7 | // 8 | // 测试修改 9 | 10 | #import "ViewController.h" 11 | 12 | #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)] 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.title = @"二级联动"; 23 | 24 | [self loadData]; 25 | [self leftTableview]; 26 | [self rightTableview]; 27 | [self lineView]; 28 | _isRelate = YES; 29 | } 30 | 31 | -(void)loadData{ 32 | _dataArray = @[@{@"title":@"第一组",@"list":@[@"1",@"one",@"two",@"three",@"foue",@"five"]}, 33 | @{@"title":@"第二组",@"list":@[@"2",@"one",@"two",@"three",@"foue",@"five"]}, 34 | @{@"title":@"第三组",@"list":@[@"3",@"one",@"two",@"three",@"foue",@"five"]}, 35 | @{@"title":@"第四组",@"list":@[@"4",@"one",@"two",@"three",@"foue",@"five"]}, 36 | @{@"title":@"第五组",@"list":@[@"5",@"one",@"two",@"three",@"foue",@"five"]}, 37 | @{@"title":@"第六组",@"list":@[@"6",@"one",@"two",@"three",@"foue",@"five"]}, 38 | @{@"title":@"第七组",@"list":@[@"7",@"one",@"two",@"three",@"foue",@"five"]}, 39 | @{@"title":@"第八组",@"list":@[@"8",@"one",@"two",@"three",@"foue",@"five"]}, 40 | @{@"title":@"第九组",@"list":@[@"9",@"one",@"two",@"three",@"foue",@"five"]}, 41 | @{@"title":@"第十组",@"list":@[@"10",@"one",@"two",@"three",@"foue",@"five"]}, 42 | @{@"title":@"第十一",@"list":@[@"11",@"one",@"two",@"three",@"foue",@"five"]}, 43 | 44 | ]; 45 | } 46 | 47 | -(UITableView *)leftTableview 48 | { 49 | if (nil == _leftTableview) { 50 | _leftTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,100, self.view.frame.size.height)]; 51 | _leftTableview.backgroundColor = [UIColor whiteColor]; 52 | _leftTableview.delegate = self; 53 | _leftTableview.dataSource = self; 54 | [self.view addSubview:_leftTableview]; 55 | } 56 | return _leftTableview; 57 | } 58 | 59 | -(UITableView *)rightTableview{ 60 | if (nil == _rightTableview) { 61 | _rightTableview = [[UITableView alloc]initWithFrame:CGRectMake(100, 0, self.view.frame.size.width - 100, self.view.frame.size.height)]; 62 | _rightTableview.backgroundColor = [UIColor whiteColor]; 63 | _rightTableview.delegate = self; 64 | _rightTableview.dataSource = self; 65 | [self.view addSubview:_rightTableview]; 66 | } 67 | return _rightTableview; 68 | } 69 | 70 | -(UIView *)lineView{ 71 | if (nil == _lineView) { 72 | _lineView = [[UIView alloc]initWithFrame:CGRectMake(100, 0, 0.5, self.view.frame.size.height)]; 73 | _lineView.backgroundColor = [UIColor blackColor]; 74 | [self.view addSubview:_lineView]; 75 | } 76 | return _lineView; 77 | } 78 | 79 | #pragma mark - 数据源方法 80 | 81 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 82 | if (tableView == self.leftTableview) { 83 | return 1; 84 | }else{ 85 | return _dataArray.count; 86 | } 87 | } 88 | 89 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 90 | NSDictionary *item = [_dataArray objectAtIndex:section]; 91 | if (tableView == self.leftTableview) { 92 | return _dataArray.count; 93 | }else{ 94 | return [[item objectForKey:@"list"]count]; 95 | } 96 | } 97 | -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 98 | static NSString *cellIndentifier = @"cell"; 99 | 100 | [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIndentifier]; 101 | 102 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier]; 103 | 104 | if (tableView == self.leftTableview) { 105 | UIView *selectedBackGroundView = [[UIView alloc]initWithFrame:cell.frame]; 106 | 107 | selectedBackGroundView.backgroundColor = RGBACOLOR(217, 217, 217, 0.5); 108 | cell.selectedBackgroundView = selectedBackGroundView; 109 | 110 | UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 5,80)]; 111 | line.backgroundColor = [UIColor orangeColor]; 112 | 113 | [selectedBackGroundView addSubview:line]; 114 | 115 | cell.textLabel.text = [_dataArray[indexPath.row]objectForKey:@"title"]; 116 | }else{ 117 | NSDictionary *item = [_dataArray objectAtIndex:indexPath.section]; 118 | cell.textLabel.text = [item objectForKey:@"list"][indexPath.row]; 119 | } 120 | return cell; 121 | } 122 | 123 | #pragma mark - 代理方法 124 | 125 | //行高 126 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 127 | if (tableView == self.leftTableview) { 128 | return 80; 129 | }else{ 130 | return 130; 131 | } 132 | } 133 | 134 | //头部高度 135 | -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ 136 | if (tableView == self.leftTableview) { 137 | return 0; 138 | }else{ 139 | return 30; 140 | } 141 | } 142 | 143 | //底部视图高度 144 | -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 145 | if (tableView == self.leftTableview) { 146 | return 0; 147 | }else{ 148 | return CGFLOAT_MIN; 149 | } 150 | } 151 | 152 | -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 153 | if (tableView == self.rightTableview) { 154 | UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)]; 155 | view.backgroundColor = RGBACOLOR(217, 217, 217, 0.7); 156 | UILabel *label = [[UILabel alloc]initWithFrame:view.bounds]; 157 | NSDictionary *item = [_dataArray objectAtIndex:section]; 158 | NSString *title = [item objectForKey:@"title"]; 159 | label.text = [NSString stringWithFormat:@" %@",title]; 160 | [view addSubview:label]; 161 | return view; 162 | }else{ 163 | return nil; 164 | } 165 | } 166 | 167 | -(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{ 168 | if (_isRelate) { 169 | NSInteger topCellSection = [[[tableView indexPathsForVisibleRows]firstObject]section]; 170 | 171 | if (tableView == self.rightTableview) { 172 | [self.leftTableview selectRowAtIndexPath:[NSIndexPath indexPathForItem:topCellSection inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle]; 173 | } 174 | } 175 | } 176 | 177 | -(void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section{ 178 | if (_isRelate) { 179 | NSInteger topCellSection = [[[tableView indexPathsForVisibleRows]firstObject]section]; 180 | if (tableView == self.rightTableview) { 181 | [self.leftTableview selectRowAtIndexPath:[NSIndexPath indexPathForItem:topCellSection inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle]; 182 | } 183 | } 184 | } 185 | 186 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 187 | if (tableView == self.leftTableview) { 188 | _isRelate = NO; 189 | [self.leftTableview selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle]; 190 | 191 | [self.rightTableview scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:indexPath.row] atScrollPosition:UITableViewScrollPositionTop animated:YES]; 192 | }else{ 193 | [self.rightTableview deselectRowAtIndexPath:indexPath animated:NO]; 194 | } 195 | } 196 | 197 | -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ 198 | _isRelate = YES; 199 | } 200 | @end 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /tableview联动/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // tableview联动 4 | // 5 | // Created by 左忠飞 on 16/6/2. 6 | // Copyright © 2016年 zzf.con. 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 | --------------------------------------------------------------------------------