Repository: DahanHu/DHCollectionTableView Branch: master Commit: 200e0cc7ef2c Files: 15 Total size: 34.6 KB Directory structure: gitextract_sztzqnm9/ ├── .gitignore ├── DHCollectionTableView/ │ ├── AppDelegate.swift │ ├── Base.lproj/ │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── DHCollectionTableViewController/ │ │ ├── DHCollectionTableViewCell.swift │ │ └── DHCollectionTableViewController.swift │ ├── Images.xcassets/ │ │ ├── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage/ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── DHCollectionTableView.xcodeproj/ │ ├── project.pbxproj │ └── project.xcworkspace/ │ ├── contents.xcworkspacedata │ └── xcshareddata/ │ └── IDEWorkspaceChecks.plist ├── LICENSE └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Xcode # build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata *.xccheckout *.moved-aside DerivedData *.hmap *.ipa *.xcuserstate *.DS_Store # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control # # Pods/ ================================================ FILE: DHCollectionTableView/AppDelegate.swift ================================================ // // AppDelegate.swift // DHCollectionTableView // // Created by 胡大函 on 14/11/3. // Copyright (c) 2014年 HuDahan_payMoreGainMore. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) let numberOfTableViewRows: NSInteger = 20 let numberOfCollectionViewCells: NSInteger = 30 var source = Array() for _ in 0..() for _ in 0..> let viewController = DHCollectionTableViewController(source: source) viewController.title = "TableView嵌套CollectionView" window?.rootViewController = UINavigationController(rootViewController: viewController) window?.makeKeyAndVisible() return true } } ================================================ FILE: DHCollectionTableView/Base.lproj/LaunchScreen.xib ================================================ ================================================ FILE: DHCollectionTableView/Base.lproj/Main.storyboard ================================================ ================================================ FILE: DHCollectionTableView/DHCollectionTableViewController/DHCollectionTableViewCell.swift ================================================ // // DHCollectionTableViewCell.swift // DHCollectionTableView // // Created by 胡大函 on 14/11/3. // Copyright (c) 2014年 HuDahan_payMoreGainMore. All rights reserved. // import UIKit class DHIndexedCollectionView: UICollectionView { var indexPath: IndexPath! override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { super.init(frame: frame, collectionViewLayout: layout) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } } let collectionViewCellIdentifier: NSString = "CollectionViewCell" class DHCollectionTableViewCell: UITableViewCell { var collectionView: DHIndexedCollectionView! override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 4, left: 5, bottom: 4, right: 5) layout.minimumLineSpacing = 5 layout.itemSize = CGSize(width: 91, height: 91) layout.scrollDirection = .horizontal collectionView = DHIndexedCollectionView(frame: CGRect.zero, collectionViewLayout: layout) collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: collectionViewCellIdentifier as String) collectionView.backgroundColor = .lightGray collectionView.showsHorizontalScrollIndicator = false contentView.addSubview(self.collectionView) layoutMargins = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func layoutSubviews() { super.layoutSubviews() let frame = self.contentView.bounds collectionView.frame = CGRect(x: 0, y: 0.5, width: frame.size.width, height: frame.size.height - 1) } func setCollectionViewDataSourceDelegate(dataSourceDelegate delegate: UICollectionViewDelegate & UICollectionViewDataSource, index: NSInteger) { collectionView.dataSource = delegate collectionView.delegate = delegate collectionView.tag = index collectionView.reloadData() } func setCollectionViewDataSourceDelegate(dataSourceDelegate delegate: UICollectionViewDelegate & UICollectionViewDataSource, indexPath: IndexPath) { collectionView.dataSource = delegate collectionView.delegate = delegate collectionView.indexPath = indexPath collectionView.tag = indexPath.section collectionView.reloadData() } } ================================================ FILE: DHCollectionTableView/DHCollectionTableViewController/DHCollectionTableViewController.swift ================================================ // // DHCollectionTableViewController.swift // DHCollectionTableView // // Created by 胡大函 on 14/11/3. // Copyright (c) 2014年 HuDahan_payMoreGainMore. All rights reserved. // import UIKit let reuseTableViewCellIdentifier = "TableViewCell" let reuseCollectionViewCellIdentifier = "CollectionViewCell" class DHCollectionTableViewController: UITableViewController { var sourceArray: Array! var contentOffsetDictionary: Dictionary! convenience init(source: Array) { self.init() tableView.register(DHCollectionTableViewCell.self, forCellReuseIdentifier: reuseTableViewCellIdentifier) tableView.separatorStyle = UITableViewCell.SeparatorStyle.none sourceArray = source contentOffsetDictionary = Dictionary() } } // MARK: - Table view data source extension DHCollectionTableViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return sourceArray.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: reuseTableViewCellIdentifier, for: indexPath) as! DHCollectionTableViewCell return cell } override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { let collectionCell = cell as! DHCollectionTableViewCell collectionCell.setCollectionViewDataSourceDelegate(dataSourceDelegate: self, index: (indexPath as NSIndexPath).row) let index = collectionCell.collectionView.tag let value = contentOffsetDictionary[index] let horizontalOffset = CGFloat(value != nil ? value!.floatValue : 0) collectionCell.collectionView.setContentOffset(CGPoint(x: horizontalOffset, y: 0), animated: false) } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 100 } } // MARK: - Collection View Data source and Delegate extension DHCollectionTableViewController:UICollectionViewDataSource,UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { let collectionViewArray = sourceArray[collectionView.tag] as! Array return collectionViewArray.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell: UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseCollectionViewCellIdentifier, for: indexPath) let collectionViewArray = sourceArray[collectionView.tag] as! Array cell.backgroundColor = collectionViewArray[(indexPath as NSIndexPath).item] as? UIColor return cell } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let itemColor: UIColor = (sourceArray[collectionView.tag] as! Array)[(indexPath as NSIndexPath).item] as! UIColor let alert = UIAlertController(title: "第\(collectionView.tag)行", message: "第\((indexPath as NSIndexPath).item)个元素", preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)) let v: UIView = UIView(frame: CGRect(x: 10, y: 20, width: 50, height: 50)) v.backgroundColor = itemColor alert.view.addSubview(v) present(alert, animated: true, completion: nil) } override func scrollViewDidScroll(_ scrollView: UIScrollView) { if !(scrollView is UICollectionView) { return } let horizontalOffset = scrollView.contentOffset.x let collectionView = scrollView as! UICollectionView contentOffsetDictionary[collectionView.tag] = horizontalOffset as AnyObject } } ================================================ FILE: DHCollectionTableView/Images.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "20x20", "scale" : "2x" }, { "idiom" : "iphone", "size" : "20x20", "scale" : "3x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "1x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "2x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "1x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x" }, { "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: DHCollectionTableView/Images.xcassets/LaunchImage.launchimage/Contents.json ================================================ { "images" : [ { "orientation" : "portrait", "idiom" : "ipad", "extent" : "full-screen", "minimum-system-version" : "7.0", "scale" : "1x" }, { "orientation" : "landscape", "idiom" : "ipad", "extent" : "full-screen", "minimum-system-version" : "7.0", "scale" : "1x" }, { "orientation" : "portrait", "idiom" : "ipad", "extent" : "full-screen", "minimum-system-version" : "7.0", "scale" : "2x" }, { "orientation" : "landscape", "idiom" : "ipad", "extent" : "full-screen", "minimum-system-version" : "7.0", "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: DHCollectionTableView/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: DHCollectionTableView/ViewController.swift ================================================ // // ViewController.swift // DHCollectionTableView // // Created by 胡大函 on 14/11/3. // Copyright (c) 2014年 HuDahan_payMoreGainMore. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } ================================================ FILE: DHCollectionTableView.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 5BB08B071A07721B0032624E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB08B061A07721B0032624E /* AppDelegate.swift */; }; 5BB08B091A07721B0032624E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB08B081A07721B0032624E /* ViewController.swift */; }; 5BB08B0C1A07721B0032624E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5BB08B0A1A07721B0032624E /* Main.storyboard */; }; 5BB08B0E1A07721B0032624E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5BB08B0D1A07721B0032624E /* Images.xcassets */; }; 5BB08B111A07721B0032624E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5BB08B0F1A07721B0032624E /* LaunchScreen.xib */; }; 5BB08B281A0774340032624E /* DHCollectionTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB08B271A0774340032624E /* DHCollectionTableViewController.swift */; }; 5BDF0BE61A07B34D0099F553 /* DHCollectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDF0BE51A07B34D0099F553 /* DHCollectionTableViewCell.swift */; }; 5BEDE5EB1A08EA5400B0E924 /* selectedItem.png in Resources */ = {isa = PBXBuildFile; fileRef = 5BEDE5E81A08EA5400B0E924 /* selectedItem.png */; }; 5BEDE5EC1A08EA5400B0E924 /* tableCollection.gif in Resources */ = {isa = PBXBuildFile; fileRef = 5BEDE5E91A08EA5400B0E924 /* tableCollection.gif */; }; 5BEDE5ED1A08EA5400B0E924 /* mainView.png in Resources */ = {isa = PBXBuildFile; fileRef = 5BEDE5EA1A08EA5400B0E924 /* mainView.png */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 5BB08B011A07721B0032624E /* DHCollectionTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DHCollectionTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5BB08B051A07721B0032624E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5BB08B061A07721B0032624E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 5BB08B081A07721B0032624E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 5BB08B0B1A07721B0032624E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 5BB08B0D1A07721B0032624E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 5BB08B101A07721B0032624E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 5BB08B271A0774340032624E /* DHCollectionTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DHCollectionTableViewController.swift; sourceTree = ""; }; 5BDF0BE51A07B34D0099F553 /* DHCollectionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DHCollectionTableViewCell.swift; sourceTree = ""; }; 5BEDE5E81A08EA5400B0E924 /* selectedItem.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = selectedItem.png; sourceTree = ""; }; 5BEDE5E91A08EA5400B0E924 /* tableCollection.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = tableCollection.gif; sourceTree = ""; }; 5BEDE5EA1A08EA5400B0E924 /* mainView.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mainView.png; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 5BB08AFE1A07721B0032624E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 5BB08AF81A07721B0032624E = { isa = PBXGroup; children = ( 5BB08B031A07721B0032624E /* DHCollectionTableView */, 5BB08B021A07721B0032624E /* Products */, ); sourceTree = ""; }; 5BB08B021A07721B0032624E /* Products */ = { isa = PBXGroup; children = ( 5BB08B011A07721B0032624E /* DHCollectionTableView.app */, ); name = Products; sourceTree = ""; }; 5BB08B031A07721B0032624E /* DHCollectionTableView */ = { isa = PBXGroup; children = ( 5BEDE5E71A08E82000B0E924 /* screenshots */, 5BB08B261A0773860032624E /* DHCollectionTableViewController */, 5BB08B061A07721B0032624E /* AppDelegate.swift */, 5BB08B081A07721B0032624E /* ViewController.swift */, 5BB08B0A1A07721B0032624E /* Main.storyboard */, 5BB08B0D1A07721B0032624E /* Images.xcassets */, 5BB08B0F1A07721B0032624E /* LaunchScreen.xib */, 5BB08B041A07721B0032624E /* Supporting Files */, ); path = DHCollectionTableView; sourceTree = ""; }; 5BB08B041A07721B0032624E /* Supporting Files */ = { isa = PBXGroup; children = ( 5BB08B051A07721B0032624E /* Info.plist */, ); name = "Supporting Files"; sourceTree = ""; }; 5BB08B261A0773860032624E /* DHCollectionTableViewController */ = { isa = PBXGroup; children = ( 5BB08B271A0774340032624E /* DHCollectionTableViewController.swift */, 5BDF0BE51A07B34D0099F553 /* DHCollectionTableViewCell.swift */, ); path = DHCollectionTableViewController; sourceTree = ""; }; 5BEDE5E71A08E82000B0E924 /* screenshots */ = { isa = PBXGroup; children = ( 5BEDE5E81A08EA5400B0E924 /* selectedItem.png */, 5BEDE5E91A08EA5400B0E924 /* tableCollection.gif */, 5BEDE5EA1A08EA5400B0E924 /* mainView.png */, ); path = screenshots; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 5BB08B001A07721B0032624E /* DHCollectionTableView */ = { isa = PBXNativeTarget; buildConfigurationList = 5BB08B201A07721B0032624E /* Build configuration list for PBXNativeTarget "DHCollectionTableView" */; buildPhases = ( 5BB08AFD1A07721B0032624E /* Sources */, 5BB08AFE1A07721B0032624E /* Frameworks */, 5BB08AFF1A07721B0032624E /* Resources */, ); buildRules = ( ); dependencies = ( ); name = DHCollectionTableView; productName = DHCollectionTableView; productReference = 5BB08B011A07721B0032624E /* DHCollectionTableView.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 5BB08AF91A07721B0032624E /* Project object */ = { isa = PBXProject; attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 1020; ORGANIZATIONNAME = HuDahan_payMoreGainMore; TargetAttributes = { 5BB08B001A07721B0032624E = { CreatedOnToolsVersion = 6.1; DevelopmentTeam = 7VLFCG84HY; LastSwiftMigration = 0900; }; }; }; buildConfigurationList = 5BB08AFC1A07721B0032624E /* Build configuration list for PBXProject "DHCollectionTableView" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 5BB08AF81A07721B0032624E; productRefGroup = 5BB08B021A07721B0032624E /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 5BB08B001A07721B0032624E /* DHCollectionTableView */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 5BB08AFF1A07721B0032624E /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 5BB08B0C1A07721B0032624E /* Main.storyboard in Resources */, 5BB08B111A07721B0032624E /* LaunchScreen.xib in Resources */, 5BEDE5EC1A08EA5400B0E924 /* tableCollection.gif in Resources */, 5BEDE5ED1A08EA5400B0E924 /* mainView.png in Resources */, 5BEDE5EB1A08EA5400B0E924 /* selectedItem.png in Resources */, 5BB08B0E1A07721B0032624E /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 5BB08AFD1A07721B0032624E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 5BB08B281A0774340032624E /* DHCollectionTableViewController.swift in Sources */, 5BDF0BE61A07B34D0099F553 /* DHCollectionTableViewCell.swift in Sources */, 5BB08B091A07721B0032624E /* ViewController.swift in Sources */, 5BB08B071A07721B0032624E /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ 5BB08B0A1A07721B0032624E /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 5BB08B0B1A07721B0032624E /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 5BB08B0F1A07721B0032624E /* LaunchScreen.xib */ = { isa = PBXVariantGroup; children = ( 5BB08B101A07721B0032624E /* Base */, ); name = LaunchScreen.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 5BB08B1E1A07721B0032624E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; 5BB08B1F1A07721B0032624E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; }; 5BB08B211A07721B0032624E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; DEVELOPMENT_TEAM = 7VLFCG84HY; INFOPLIST_FILE = DHCollectionTableView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dahan.DHCollectionTableView; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 5.0; }; name = Debug; }; 5BB08B221A07721B0032624E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; DEVELOPMENT_TEAM = 7VLFCG84HY; INFOPLIST_FILE = DHCollectionTableView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dahan.DHCollectionTableView; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 5.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 5BB08AFC1A07721B0032624E /* Build configuration list for PBXProject "DHCollectionTableView" */ = { isa = XCConfigurationList; buildConfigurations = ( 5BB08B1E1A07721B0032624E /* Debug */, 5BB08B1F1A07721B0032624E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 5BB08B201A07721B0032624E /* Build configuration list for PBXNativeTarget "DHCollectionTableView" */ = { isa = XCConfigurationList; buildConfigurations = ( 5BB08B211A07721B0032624E /* Debug */, 5BB08B221A07721B0032624E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 5BB08AF91A07721B0032624E /* Project object */; } ================================================ FILE: DHCollectionTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: DHCollectionTableView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ================================================ IDEDidComputeMac32BitWarning ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2014 Dahan Hu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ DHCollectionTableView ===================== #### 用Swift实现UITableView内嵌套UICollectionView的效果如下:
#### 不用担心每个item的索引获取
How to use ========== // source就是要显示的数据,图片什么的,随意啦, format: Array> let viewController = DHCollectionTableViewController(source: mutableArray) self.root = UINavigationController(rootViewController: viewController) Thanks ====== Ash Furrow's objc-proj on GitHub: https://github.com/AshFurrow/AFTabledCollectionView License ======= These specifications and CocoaPods are available under the [MIT license](http://opensource.org/licenses/mit-license.php).