├── 导航栏联动.gif ├── MenuLinkageDemo.zip ├── UITableView双级联动.gif ├── 获取UITableView中心线cell.gif ├── TableView双级联动.xcodeproj ├── xcuserdata │ └── wangshuanglong.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcuserdata │ │ └── wangshuanglong.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── project.pbxproj ├── TableView双级联动 ├── ViewController.h ├── AppDelegate.h ├── main.m ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard ├── PrefixHeader.pch ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── AppDelegate.m └── ViewController.m ├── TableView双级联动Tests ├── Info.plist └── TableView____Tests.m ├── TableView双级联动UITests ├── Info.plist └── TableView____UITests.m └── README.md /导航栏联动.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wsl2ls/UITableViewLinkage/HEAD/导航栏联动.gif -------------------------------------------------------------------------------- /MenuLinkageDemo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wsl2ls/UITableViewLinkage/HEAD/MenuLinkageDemo.zip -------------------------------------------------------------------------------- /UITableView双级联动.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wsl2ls/UITableViewLinkage/HEAD/UITableView双级联动.gif -------------------------------------------------------------------------------- /获取UITableView中心线cell.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wsl2ls/UITableViewLinkage/HEAD/获取UITableView中心线cell.gif -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/xcuserdata/wangshuanglong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/project.xcworkspace/xcuserdata/wangshuanglong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wsl2ls/UITableViewLinkage/HEAD/TableView双级联动.xcodeproj/project.xcworkspace/xcuserdata/wangshuanglong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /TableView双级联动/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TableView双级联动 4 | // 5 | // Created by 王双龙 on 2018/3/30. 6 | // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TableView双级联动/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TableView双级联动 4 | // 5 | // Created by 王双龙 on 2018/3/30. 6 | // Copyright © 2018年 王双龙. 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双级联动/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TableView双级联动 4 | // 5 | // Created by 王双龙 on 2018/3/30. 6 | // Copyright © 2018年 王双龙. 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 | -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/xcuserdata/wangshuanglong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | TableView双级联动.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /TableView双级联动Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TableView双级联动UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TableView双级联动Tests/TableView____Tests.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ : XCTestCase 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)setUp { 12 | [super setUp]; 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | } 15 | 16 | - (void)tearDown { 17 | // Put teardown code here. This method is called after the invocation of each test method in the class. 18 | [super tearDown]; 19 | } 20 | 21 | - (void)testExample { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | - (void)testPerformanceExample { 27 | // This is an example of a performance test case. 28 | [self measureBlock:^{ 29 | // Put the code you want to measure the time of here. 30 | }]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /TableView双级联动UITests/TableView____UITests.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ : XCTestCase 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)setUp { 12 | [super setUp]; 13 | 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | self.continueAfterFailure = NO; 18 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 19 | [[[XCUIApplication alloc] init] launch]; 20 | 21 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 22 | } 23 | 24 | - (void)tearDown { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample { 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /TableView双级联动/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /TableView双级联动/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // 4 | // Created by 王双龙 on 2018/3/30. 5 | // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea All rights reserved. 6 | // 7 | 8 | #ifndef PrefixHeader_pch 9 | #define PrefixHeader_pch 10 | 11 | 12 | //竖屏幕宽高 13 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 14 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 15 | 16 | //设备型号 17 | #define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) 18 | #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) 19 | #define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO) 20 | #define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO) 21 | #define iPhone6PlusScale ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) : NO) 22 | #define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) 23 | 24 | //导航栏 25 | #define StatusBarHeight (iPhoneX ? 44.f : 20.f) 26 | #define StatusBarAndNavigationBarHeight (iPhoneX ? 88.f : 64.f) 27 | #define TabbarHeight (iPhoneX ? (49.f + 34.f) : (49.f)) 28 | #define BottomSafeAreaHeight (iPhoneX ? (34.f) : (0.f)) 29 | 30 | 31 | 32 | #endif /* PrefixHeader_pch */ 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /TableView双级联动/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /TableView双级联动/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TableView双级联动 4 | // 5 | // Created by 王双龙 on 2018/3/30. 6 | // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 简书地址: https://www.jianshu.com/p/70cdcdcb6764 2 | 3 | > UITableView/UICollectionView获取特定位置的cell 主要依赖于各自对象提供的的api方法,应用示例如下: 4 | 5 | ``` 6 | // returns nil if point is outside of any row in the table 7 | //tableView 8 | - (nullable NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point; 9 | //collectionView 10 | - (nullable NSIndexPath *)indexPathForItemAtPoint:(CGPoint)point; 11 | ``` 12 | 13 | ## 一、tableView双级联动 14 | 15 | ![菜单栏联动.gif](https://upload-images.jianshu.io/upload_images/1708447-b44dc69659741fac.gif?imageMogr2/auto-orient/strip) 16 | 17 | ![UITableView双级联动.gif](https://upload-images.jianshu.io/upload_images/1708447-a2963052ab3aef19.gif?imageMogr2/auto-orient/strip) 18 | 19 | > 以上两种效果比较类似,实现的关键在于都是需要获得在滑动过程中滑动到tableView顶部的cell的indexPath。 20 | 21 | ##### 方案一(不推荐原因会在后面提到):获得当前可见的所有cell,然后取可见cell数组中的第一个cell就是目标cell,再根据cell获得indexPath。代码如下 22 | 23 | ``` 24 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 25 | 26 | if (scrollView == _rightTableView && _isSelected == NO) { 27 | //返回tableView可见的cell数组 28 | NSArray * array = [_rightTableView visibleCells]; 29 | //返回cell的IndexPath 30 | NSIndexPath * indexPath = [_rightTableView indexPathForCell:array.firstObject]; 31 | NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 32 | _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; 33 | [_leftTableView reloadData]; 34 | [_leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; 35 | } 36 | 37 | } 38 | 39 | ``` 40 | 41 | ##### 方案二(推荐使用):利用偏移量!偏移量的值实际上可以代表当时处于tableView顶部的cell在tableView上的相对位置, 那么我们就可以根据偏移量获得处于顶部的cell的indexPath。代码如下 42 | 43 | ``` 44 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 45 | 46 | if (scrollView == _rightTableView && _isSelected == NO) { 47 | //系统方法返回处于tableView某坐标处的cell的indexPath 48 | NSIndexPath * indexPath = [_rightTableView indexPathForRowAtPoint:scrollView.contentOffset]; 49 | NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 50 | _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; 51 | [_leftTableView reloadData]; 52 | [_leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; 53 | } 54 | 55 | } 56 | 57 | ``` 58 | 59 | ## 二、 获取处于UITableView中心的cell 60 | 61 | ![获取UITableView中心线cell.gif](https://upload-images.jianshu.io/upload_images/1708447-fb94b116b561de01.gif?imageMogr2/auto-orient/strip) 62 | 63 | > 获取处于tableView中间cell的效果,用上述**方案一**比较麻烦:要考虑可见cell 的奇、偶个数问题,还有cell是否等高的情况;**方案二**用起来就快捷方便多了,取的cell的位置的纵坐标相当于在偏移量的基础上又增加了tableView高度的一半。代码如下: 64 | 65 | ``` 66 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 67 | 68 | //获取处于UITableView中心的cell 69 | //系统方法返回处于tableView某坐标处的cell的indexPath 70 | NSIndexPath * middleIndexPath = [_rightTableView indexPathForRowAtPoint:CGPointMake(0, scrollView.contentOffset.y + _rightTableView.frame.size.height/2)]; 71 | NSLog(@"中间的cell:第 %ld 组 %ld个",middleIndexPath.section, middleIndexPath.row); 72 | } 73 | 74 | ``` 75 | 76 | >俺目前能想到的也就这了,各位同僚有什么好的想法欢迎在此留言交流😀😁😀👏👏👏 77 | 78 | 79 | > 更新于2018/9/7 :UICollectionView获取特定位置的item与UITableView相似,仅仅是获取的方法名不同,如下: 80 | 81 | ``` 82 | NSIndexPath * indexPath = [_collectionView indexPathForItemAtPoint:scrollView.contentOffset]; 83 | NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 84 | 85 | ``` 86 | 87 | > 获取手指在UIScrollView上的滑动速率、方向以及移动距离 88 | 89 | ``` 90 | 91 | // velocityInView: 手指在视图上移动的速度(x,y), 正负也是代表方向,值得一体的是在绝对值上|x| > |y| 水平移动, |y|>|x| 竖直移动。 92 | CGPoint velocity = [scrollView.panGestureRecognizer velocityInView:scrollView]; 93 | 94 | //translationInView : 手指在视图上移动的位置(x,y)向下和向右为正,向上和向左为负。X和Y的数值都是距离手指起始位置的距离 95 | CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview]; 96 | 97 | ``` 98 | 99 | ![](https://upload-images.jianshu.io/upload_images/1708447-8c0b18a244d9270b.gif?imageMogr2/auto-orient/strip) 100 | 101 | 欢迎扫描下方二维码关注——iOS开发进阶之路——微信公众号:iOS2679114653 本公众号是一个iOS开发者们的分享,交流,学习平台,会不定时的发送技术干货,源码,也欢迎大家积极踊跃投稿,(择优上头条) ^_^分享自己开发攻城的过程,心得,相互学习,共同进步,成为攻城狮中的翘楚! 102 | 103 | ![iOS开发进阶之路.jpg](http://upload-images.jianshu.io/upload_images/1708447-c2471528cadd7c86.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 104 | -------------------------------------------------------------------------------- /TableView双级联动/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TableView双级联动 4 | // 5 | // Created by 王双龙 on 2018/3/30. 6 | // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "PrefixHeader.pch" 11 | 12 | 13 | @interface ViewController () 14 | 15 | @property (nonatomic, strong) UITableView * leftTableView; 16 | 17 | @property (nonatomic, strong) UITableView * rightTableView; 18 | 19 | /** 20 | 滑到了第几组 21 | */ 22 | @property (nonatomic, strong) NSIndexPath * currentIndexPath; 23 | 24 | //用来处理leftTableView的cell的点击事件引起的rightTableView的滑动和用户拖拽rightTableView的事件冲突 25 | @property (nonatomic, assign) BOOL isSelected; 26 | 27 | @end 28 | 29 | @implementation ViewController 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | 34 | _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 35 | [self.view addSubview:self.leftTableView]; 36 | [self.view addSubview:self.rightTableView]; 37 | 38 | } 39 | 40 | #pragma mark -- Getter 41 | 42 | - (UITableView *)leftTableView{ 43 | 44 | if (_leftTableView == nil) { 45 | _leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, StatusBarHeight, SCREEN_WIDTH / 3.0, SCREEN_HEIGHT - StatusBarHeight) style:UITableViewStyleGrouped]; 46 | _leftTableView.delegate = self; 47 | _leftTableView.dataSource = self; 48 | } 49 | return _leftTableView; 50 | } 51 | 52 | - (UITableView *)rightTableView{ 53 | 54 | if (_rightTableView == nil) { 55 | _rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 3.0, StatusBarHeight, SCREEN_WIDTH / 3.0 * 2, SCREEN_HEIGHT - StatusBarHeight) style:UITableViewStylePlain]; 56 | _rightTableView.delegate = self; 57 | _rightTableView.dataSource = self; 58 | } 59 | return _rightTableView; 60 | } 61 | 62 | #pragma mark -- UITableViewDelegate UITableViewDataSource 63 | 64 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 65 | return 20; 66 | } 67 | 68 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 69 | if (tableView == _leftTableView) { 70 | return 1; 71 | } 72 | return 5; 73 | } 74 | 75 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 76 | if (tableView == _leftTableView) { 77 | return 44; 78 | } 79 | return 60; 80 | } 81 | 82 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ 83 | if (tableView == _leftTableView) { 84 | return 0.01; 85 | } 86 | return 30; 87 | } 88 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 89 | if (tableView == _leftTableView) { 90 | return nil; 91 | } 92 | 93 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)]; 94 | label.textAlignment = NSTextAlignmentCenter; 95 | label.textColor = [UIColor blueColor]; 96 | label.text = [NSString stringWithFormat:@"第%ld组",section]; 97 | return label; 98 | } 99 | 100 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 101 | return 0.1; 102 | } 103 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ 104 | return nil; 105 | } 106 | 107 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 108 | 109 | UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"]; 110 | if (cell == nil) { 111 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"]; 112 | } 113 | 114 | if (tableView == _leftTableView) { 115 | cell.textLabel.text = [NSString stringWithFormat:@"第%ld组",indexPath.section]; 116 | if (indexPath == _currentIndexPath) { 117 | cell.textLabel.textColor = [UIColor greenColor]; 118 | }else{ 119 | cell.textLabel.textColor = [UIColor blackColor]; 120 | } 121 | return cell; 122 | } 123 | 124 | cell.textLabel.text = [NSString stringWithFormat:@"第%ld组内的商品",(long)indexPath.section]; 125 | return cell; 126 | } 127 | 128 | - (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 129 | 130 | [tableView deselectRowAtIndexPath:indexPath animated:NO]; 131 | 132 | if (tableView == _leftTableView) { 133 | _currentIndexPath = indexPath; 134 | [tableView reloadData]; 135 | [_rightTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionTop animated:YES]; 136 | _isSelected = YES; 137 | } 138 | 139 | } 140 | 141 | #pragma mark -- UIScrollViewDelegate 142 | 143 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 144 | 145 | //方案一 146 | // if (scrollView == _rightTableView && _isSelected == NO) { 147 | //返回tableView可见的cell数组 148 | // NSArray * array = [_rightTableView visibleCells]; 149 | //返回cell的IndexPath 150 | // NSIndexPath * indexPath = [_rightTableView indexPathForCell:array.firstObject]; 151 | // NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 152 | // _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; 153 | // [_leftTableView reloadData]; 154 | // [_leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; 155 | // } 156 | 157 | //方案二 158 | if (scrollView == _rightTableView && _isSelected == NO) { 159 | //系统方法返回处于tableView某坐标处的cell的indexPath 160 | NSIndexPath * indexPath = [_rightTableView indexPathForRowAtPoint:scrollView.contentOffset]; 161 | NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 162 | _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; 163 | [_leftTableView reloadData]; 164 | [_leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; 165 | } 166 | 167 | //获取处于UITableView中心的cell 168 | //系统方法返回处于tableView某坐标处的cell的indexPath 169 | NSIndexPath * middleIndexPath = [_rightTableView indexPathForRowAtPoint:CGPointMake(0, scrollView.contentOffset.y + _rightTableView.frame.size.height/2)]; 170 | NSLog(@"中间的cell:第 %ld 组 %ld个",middleIndexPath.section, middleIndexPath.row); 171 | 172 | //获取某个cell在当前tableView上的坐标位置 173 | CGRect rectInTableView = [_rightTableView rectForRowAtIndexPath:middleIndexPath]; 174 | //获取cell在当前屏幕的位置 175 | CGRect rectInSuperview = [_rightTableView convertRect:rectInTableView toView:[_rightTableView superview]]; 176 | NSLog(@"中间的cell处于tableView上的位置: %@ /n 中间cell在当前屏幕的位置:%@", NSStringFromCGRect(rectInTableView), NSStringFromCGRect(rectInSuperview)); 177 | 178 | /*UICollectionView同理也可实现 179 | NSIndexPath * indexPath = [collectionView indexPathForItemAtPoint:scrollView.contentOffset]; 180 | NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); 181 | 182 | //获取cell在当前collection的位置 183 | CGRect cellInCollection = [_collectionView convertRect:item.frame toView:_collectionView]; 184 | UICollectionViewCell * item = [_collectionView cellForItemAtIndexPath:indexPath]]; 185 | //获取cell在当前屏幕的位置 186 | CGRect cellInSuperview = [_collectionView convertRect:item.frame toView:[_collectionView superview]]; 187 | NSLog(@"获取cell在当前collection的位置: %@ /n 获取cell在当前屏幕的位置:%@", NSStringFromCGRect(cellInCollection), NSStringFromCGRect(cellInSuperview)); 188 | */ 189 | } 190 | 191 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ 192 | _isSelected = NO; 193 | } 194 | 195 | 196 | - (void)didReceiveMemoryWarning { 197 | [super didReceiveMemoryWarning]; 198 | // Dispose of any resources that can be recreated. 199 | } 200 | 201 | 202 | @end 203 | -------------------------------------------------------------------------------- /TableView双级联动.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 310E07A6206DCFAF004B8830 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 310E07A5206DCFAF004B8830 /* AppDelegate.m */; }; 11 | 310E07A9206DCFAF004B8830 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 310E07A8206DCFAF004B8830 /* ViewController.m */; }; 12 | 310E07AC206DCFAF004B8830 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 310E07AA206DCFAF004B8830 /* Main.storyboard */; }; 13 | 310E07AE206DCFAF004B8830 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 310E07AD206DCFAF004B8830 /* Assets.xcassets */; }; 14 | 310E07B1206DCFAF004B8830 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 310E07AF206DCFAF004B8830 /* LaunchScreen.storyboard */; }; 15 | 310E07B4206DCFAF004B8830 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 310E07B3206DCFAF004B8830 /* main.m */; }; 16 | 310E07BE206DCFB0004B8830 /* TableView____Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 310E07BD206DCFB0004B8830 /* TableView____Tests.m */; }; 17 | 310E07C9206DCFB0004B8830 /* TableView____UITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 310E07C8206DCFB0004B8830 /* TableView____UITests.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 310E07BA206DCFB0004B8830 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 310E0799206DCFAF004B8830 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 310E07A0206DCFAF004B8830; 26 | remoteInfo = "TableView双级联动"; 27 | }; 28 | 310E07C5206DCFB0004B8830 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 310E0799206DCFAF004B8830 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 310E07A0206DCFAF004B8830; 33 | remoteInfo = "TableView双级联动"; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 310E07A1206DCFAF004B8830 /* TableView双级联动.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TableView双级联动.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 310E07A4206DCFAF004B8830 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | 310E07A5206DCFAF004B8830 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | 310E07A7206DCFAF004B8830 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | 310E07A8206DCFAF004B8830 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | 310E07AB206DCFAF004B8830 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | 310E07AD206DCFAF004B8830 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | 310E07B0206DCFAF004B8830 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | 310E07B2206DCFAF004B8830 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | 310E07B3206DCFAF004B8830 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | 310E07B9206DCFB0004B8830 /* TableView双级联动Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "TableView双级联动Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 310E07BD206DCFB0004B8830 /* TableView____Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "TableView____Tests.m"; sourceTree = ""; }; 50 | 310E07BF206DCFB0004B8830 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 310E07C4206DCFB0004B8830 /* TableView双级联动UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "TableView双级联动UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 310E07C8206DCFB0004B8830 /* TableView____UITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "TableView____UITests.m"; sourceTree = ""; }; 53 | 310E07CA206DCFB0004B8830 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 310E07D9206DDDB0004B8830 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 310E079E206DCFAF004B8830 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 310E07B6206DCFB0004B8830 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | 310E07C1206DCFB0004B8830 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | 310E0798206DCFAF004B8830 = { 83 | isa = PBXGroup; 84 | children = ( 85 | 310E07A3206DCFAF004B8830 /* TableView双级联动 */, 86 | 310E07BC206DCFB0004B8830 /* TableView双级联动Tests */, 87 | 310E07C7206DCFB0004B8830 /* TableView双级联动UITests */, 88 | 310E07A2206DCFAF004B8830 /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | 310E07A2206DCFAF004B8830 /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 310E07A1206DCFAF004B8830 /* TableView双级联动.app */, 96 | 310E07B9206DCFB0004B8830 /* TableView双级联动Tests.xctest */, 97 | 310E07C4206DCFB0004B8830 /* TableView双级联动UITests.xctest */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 310E07A3206DCFAF004B8830 /* TableView双级联动 */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 310E07A4206DCFAF004B8830 /* AppDelegate.h */, 106 | 310E07A5206DCFAF004B8830 /* AppDelegate.m */, 107 | 310E07A7206DCFAF004B8830 /* ViewController.h */, 108 | 310E07A8206DCFAF004B8830 /* ViewController.m */, 109 | 310E07D9206DDDB0004B8830 /* PrefixHeader.pch */, 110 | 310E07AA206DCFAF004B8830 /* Main.storyboard */, 111 | 310E07AD206DCFAF004B8830 /* Assets.xcassets */, 112 | 310E07AF206DCFAF004B8830 /* LaunchScreen.storyboard */, 113 | 310E07B2206DCFAF004B8830 /* Info.plist */, 114 | 310E07B3206DCFAF004B8830 /* main.m */, 115 | ); 116 | path = "TableView双级联动"; 117 | sourceTree = ""; 118 | }; 119 | 310E07BC206DCFB0004B8830 /* TableView双级联动Tests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 310E07BD206DCFB0004B8830 /* TableView____Tests.m */, 123 | 310E07BF206DCFB0004B8830 /* Info.plist */, 124 | ); 125 | path = "TableView双级联动Tests"; 126 | sourceTree = ""; 127 | }; 128 | 310E07C7206DCFB0004B8830 /* TableView双级联动UITests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 310E07C8206DCFB0004B8830 /* TableView____UITests.m */, 132 | 310E07CA206DCFB0004B8830 /* Info.plist */, 133 | ); 134 | path = "TableView双级联动UITests"; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 310E07A0206DCFAF004B8830 /* TableView双级联动 */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 310E07CD206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动" */; 143 | buildPhases = ( 144 | 310E079D206DCFAF004B8830 /* Sources */, 145 | 310E079E206DCFAF004B8830 /* Frameworks */, 146 | 310E079F206DCFAF004B8830 /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = "TableView双级联动"; 153 | productName = "TableView双级联动"; 154 | productReference = 310E07A1206DCFAF004B8830 /* TableView双级联动.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | 310E07B8206DCFB0004B8830 /* TableView双级联动Tests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 310E07D0206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动Tests" */; 160 | buildPhases = ( 161 | 310E07B5206DCFB0004B8830 /* Sources */, 162 | 310E07B6206DCFB0004B8830 /* Frameworks */, 163 | 310E07B7206DCFB0004B8830 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | 310E07BB206DCFB0004B8830 /* PBXTargetDependency */, 169 | ); 170 | name = "TableView双级联动Tests"; 171 | productName = "TableView双级联动Tests"; 172 | productReference = 310E07B9206DCFB0004B8830 /* TableView双级联动Tests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | 310E07C3206DCFB0004B8830 /* TableView双级联动UITests */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = 310E07D3206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动UITests" */; 178 | buildPhases = ( 179 | 310E07C0206DCFB0004B8830 /* Sources */, 180 | 310E07C1206DCFB0004B8830 /* Frameworks */, 181 | 310E07C2206DCFB0004B8830 /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | 310E07C6206DCFB0004B8830 /* PBXTargetDependency */, 187 | ); 188 | name = "TableView双级联动UITests"; 189 | productName = "TableView双级联动UITests"; 190 | productReference = 310E07C4206DCFB0004B8830 /* TableView双级联动UITests.xctest */; 191 | productType = "com.apple.product-type.bundle.ui-testing"; 192 | }; 193 | /* End PBXNativeTarget section */ 194 | 195 | /* Begin PBXProject section */ 196 | 310E0799206DCFAF004B8830 /* Project object */ = { 197 | isa = PBXProject; 198 | attributes = { 199 | LastUpgradeCheck = 0920; 200 | ORGANIZATIONNAME = "王双龙"; 201 | TargetAttributes = { 202 | 310E07A0206DCFAF004B8830 = { 203 | CreatedOnToolsVersion = 9.2; 204 | ProvisioningStyle = Automatic; 205 | }; 206 | 310E07B8206DCFB0004B8830 = { 207 | CreatedOnToolsVersion = 9.2; 208 | ProvisioningStyle = Automatic; 209 | TestTargetID = 310E07A0206DCFAF004B8830; 210 | }; 211 | 310E07C3206DCFB0004B8830 = { 212 | CreatedOnToolsVersion = 9.2; 213 | ProvisioningStyle = Automatic; 214 | TestTargetID = 310E07A0206DCFAF004B8830; 215 | }; 216 | }; 217 | }; 218 | buildConfigurationList = 310E079C206DCFAF004B8830 /* Build configuration list for PBXProject "TableView双级联动" */; 219 | compatibilityVersion = "Xcode 8.0"; 220 | developmentRegion = en; 221 | hasScannedForEncodings = 0; 222 | knownRegions = ( 223 | en, 224 | Base, 225 | ); 226 | mainGroup = 310E0798206DCFAF004B8830; 227 | productRefGroup = 310E07A2206DCFAF004B8830 /* Products */; 228 | projectDirPath = ""; 229 | projectRoot = ""; 230 | targets = ( 231 | 310E07A0206DCFAF004B8830 /* TableView双级联动 */, 232 | 310E07B8206DCFB0004B8830 /* TableView双级联动Tests */, 233 | 310E07C3206DCFB0004B8830 /* TableView双级联动UITests */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | 310E079F206DCFAF004B8830 /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | 310E07B1206DCFAF004B8830 /* LaunchScreen.storyboard in Resources */, 244 | 310E07AE206DCFAF004B8830 /* Assets.xcassets in Resources */, 245 | 310E07AC206DCFAF004B8830 /* Main.storyboard in Resources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | 310E07B7206DCFB0004B8830 /* Resources */ = { 250 | isa = PBXResourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | 310E07C2206DCFB0004B8830 /* Resources */ = { 257 | isa = PBXResourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXSourcesBuildPhase section */ 266 | 310E079D206DCFAF004B8830 /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | 310E07A9206DCFAF004B8830 /* ViewController.m in Sources */, 271 | 310E07B4206DCFAF004B8830 /* main.m in Sources */, 272 | 310E07A6206DCFAF004B8830 /* AppDelegate.m in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 310E07B5206DCFB0004B8830 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | 310E07BE206DCFB0004B8830 /* TableView____Tests.m in Sources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | 310E07C0206DCFB0004B8830 /* Sources */ = { 285 | isa = PBXSourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | 310E07C9206DCFB0004B8830 /* TableView____UITests.m in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXSourcesBuildPhase section */ 293 | 294 | /* Begin PBXTargetDependency section */ 295 | 310E07BB206DCFB0004B8830 /* PBXTargetDependency */ = { 296 | isa = PBXTargetDependency; 297 | target = 310E07A0206DCFAF004B8830 /* TableView双级联动 */; 298 | targetProxy = 310E07BA206DCFB0004B8830 /* PBXContainerItemProxy */; 299 | }; 300 | 310E07C6206DCFB0004B8830 /* PBXTargetDependency */ = { 301 | isa = PBXTargetDependency; 302 | target = 310E07A0206DCFAF004B8830 /* TableView双级联动 */; 303 | targetProxy = 310E07C5206DCFB0004B8830 /* PBXContainerItemProxy */; 304 | }; 305 | /* End PBXTargetDependency section */ 306 | 307 | /* Begin PBXVariantGroup section */ 308 | 310E07AA206DCFAF004B8830 /* Main.storyboard */ = { 309 | isa = PBXVariantGroup; 310 | children = ( 311 | 310E07AB206DCFAF004B8830 /* Base */, 312 | ); 313 | name = Main.storyboard; 314 | sourceTree = ""; 315 | }; 316 | 310E07AF206DCFAF004B8830 /* LaunchScreen.storyboard */ = { 317 | isa = PBXVariantGroup; 318 | children = ( 319 | 310E07B0206DCFAF004B8830 /* Base */, 320 | ); 321 | name = LaunchScreen.storyboard; 322 | sourceTree = ""; 323 | }; 324 | /* End PBXVariantGroup section */ 325 | 326 | /* Begin XCBuildConfiguration section */ 327 | 310E07CB206DCFB0004B8830 /* Debug */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_ANALYZER_NONNULL = YES; 332 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 338 | CLANG_WARN_BOOL_CONVERSION = YES; 339 | CLANG_WARN_COMMA = YES; 340 | CLANG_WARN_CONSTANT_CONVERSION = YES; 341 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 342 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 343 | CLANG_WARN_EMPTY_BODY = YES; 344 | CLANG_WARN_ENUM_CONVERSION = YES; 345 | CLANG_WARN_INFINITE_RECURSION = YES; 346 | CLANG_WARN_INT_CONVERSION = YES; 347 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 348 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 349 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 350 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 351 | CLANG_WARN_STRICT_PROTOTYPES = YES; 352 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 353 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 354 | CLANG_WARN_UNREACHABLE_CODE = YES; 355 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 356 | CODE_SIGN_IDENTITY = "iPhone Developer"; 357 | COPY_PHASE_STRIP = NO; 358 | DEBUG_INFORMATION_FORMAT = dwarf; 359 | ENABLE_STRICT_OBJC_MSGSEND = YES; 360 | ENABLE_TESTABILITY = YES; 361 | GCC_C_LANGUAGE_STANDARD = gnu11; 362 | GCC_DYNAMIC_NO_PIC = NO; 363 | GCC_NO_COMMON_BLOCKS = YES; 364 | GCC_OPTIMIZATION_LEVEL = 0; 365 | GCC_PREPROCESSOR_DEFINITIONS = ( 366 | "DEBUG=1", 367 | "$(inherited)", 368 | ); 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 376 | MTL_ENABLE_DEBUG_INFO = YES; 377 | ONLY_ACTIVE_ARCH = YES; 378 | SDKROOT = iphoneos; 379 | }; 380 | name = Debug; 381 | }; 382 | 310E07CC206DCFB0004B8830 /* Release */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ALWAYS_SEARCH_USER_PATHS = NO; 386 | CLANG_ANALYZER_NONNULL = YES; 387 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 388 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 389 | CLANG_CXX_LIBRARY = "libc++"; 390 | CLANG_ENABLE_MODULES = YES; 391 | CLANG_ENABLE_OBJC_ARC = YES; 392 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 393 | CLANG_WARN_BOOL_CONVERSION = YES; 394 | CLANG_WARN_COMMA = YES; 395 | CLANG_WARN_CONSTANT_CONVERSION = YES; 396 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 397 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 398 | CLANG_WARN_EMPTY_BODY = YES; 399 | CLANG_WARN_ENUM_CONVERSION = YES; 400 | CLANG_WARN_INFINITE_RECURSION = YES; 401 | CLANG_WARN_INT_CONVERSION = YES; 402 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 403 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 404 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 405 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 406 | CLANG_WARN_STRICT_PROTOTYPES = YES; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 409 | CLANG_WARN_UNREACHABLE_CODE = YES; 410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 411 | CODE_SIGN_IDENTITY = "iPhone Developer"; 412 | COPY_PHASE_STRIP = NO; 413 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 414 | ENABLE_NS_ASSERTIONS = NO; 415 | ENABLE_STRICT_OBJC_MSGSEND = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu11; 417 | GCC_NO_COMMON_BLOCKS = YES; 418 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 419 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 420 | GCC_WARN_UNDECLARED_SELECTOR = YES; 421 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 422 | GCC_WARN_UNUSED_FUNCTION = YES; 423 | GCC_WARN_UNUSED_VARIABLE = YES; 424 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 425 | MTL_ENABLE_DEBUG_INFO = NO; 426 | SDKROOT = iphoneos; 427 | VALIDATE_PRODUCT = YES; 428 | }; 429 | name = Release; 430 | }; 431 | 310E07CE206DCFB0004B8830 /* Debug */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 435 | CODE_SIGN_STYLE = Automatic; 436 | INFOPLIST_FILE = "TableView双级联动/Info.plist"; 437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 438 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----"; 439 | PRODUCT_NAME = "$(TARGET_NAME)"; 440 | TARGETED_DEVICE_FAMILY = "1,2"; 441 | }; 442 | name = Debug; 443 | }; 444 | 310E07CF206DCFB0004B8830 /* Release */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | CODE_SIGN_STYLE = Automatic; 449 | INFOPLIST_FILE = "TableView双级联动/Info.plist"; 450 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 451 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----"; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | TARGETED_DEVICE_FAMILY = "1,2"; 454 | }; 455 | name = Release; 456 | }; 457 | 310E07D1206DCFB0004B8830 /* Debug */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | BUNDLE_LOADER = "$(TEST_HOST)"; 461 | CODE_SIGN_STYLE = Automatic; 462 | INFOPLIST_FILE = "TableView双级联动Tests/Info.plist"; 463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 464 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----Tests"; 465 | PRODUCT_NAME = "$(TARGET_NAME)"; 466 | TARGETED_DEVICE_FAMILY = "1,2"; 467 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TableView双级联动.app/TableView双级联动"; 468 | }; 469 | name = Debug; 470 | }; 471 | 310E07D2206DCFB0004B8830 /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | BUNDLE_LOADER = "$(TEST_HOST)"; 475 | CODE_SIGN_STYLE = Automatic; 476 | INFOPLIST_FILE = "TableView双级联动Tests/Info.plist"; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----Tests"; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TableView双级联动.app/TableView双级联动"; 482 | }; 483 | name = Release; 484 | }; 485 | 310E07D4206DCFB0004B8830 /* Debug */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | CODE_SIGN_STYLE = Automatic; 489 | INFOPLIST_FILE = "TableView双级联动UITests/Info.plist"; 490 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 491 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----UITests"; 492 | PRODUCT_NAME = "$(TARGET_NAME)"; 493 | TARGETED_DEVICE_FAMILY = "1,2"; 494 | TEST_TARGET_NAME = "TableView双级联动"; 495 | }; 496 | name = Debug; 497 | }; 498 | 310E07D5206DCFB0004B8830 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | CODE_SIGN_STYLE = Automatic; 502 | INFOPLIST_FILE = "TableView双级联动UITests/Info.plist"; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = "com.chinaDaily.TableView----UITests"; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TARGETED_DEVICE_FAMILY = "1,2"; 507 | TEST_TARGET_NAME = "TableView双级联动"; 508 | }; 509 | name = Release; 510 | }; 511 | /* End XCBuildConfiguration section */ 512 | 513 | /* Begin XCConfigurationList section */ 514 | 310E079C206DCFAF004B8830 /* Build configuration list for PBXProject "TableView双级联动" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | 310E07CB206DCFB0004B8830 /* Debug */, 518 | 310E07CC206DCFB0004B8830 /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | defaultConfigurationName = Release; 522 | }; 523 | 310E07CD206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 310E07CE206DCFB0004B8830 /* Debug */, 527 | 310E07CF206DCFB0004B8830 /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | 310E07D0206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动Tests" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 310E07D1206DCFB0004B8830 /* Debug */, 536 | 310E07D2206DCFB0004B8830 /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | defaultConfigurationName = Release; 540 | }; 541 | 310E07D3206DCFB0004B8830 /* Build configuration list for PBXNativeTarget "TableView双级联动UITests" */ = { 542 | isa = XCConfigurationList; 543 | buildConfigurations = ( 544 | 310E07D4206DCFB0004B8830 /* Debug */, 545 | 310E07D5206DCFB0004B8830 /* Release */, 546 | ); 547 | defaultConfigurationIsVisible = 0; 548 | defaultConfigurationName = Release; 549 | }; 550 | /* End XCConfigurationList section */ 551 | }; 552 | rootObject = 310E0799206DCFAF004B8830 /* Project object */; 553 | } 554 | --------------------------------------------------------------------------------