From b6070acbaef7888547bfcfb15f9070ae7d5053ed Mon Sep 17 00:00:00 2001 From: 15038777234 <15038777234@163.com> Date: Mon, 20 Mar 2017 09:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project.pbxproj | 6 +- README.md | 145 ++++++++++-------- ...up.podspec => ZHTableViewGroupObjc.podspec | 4 +- 3 files changed, 86 insertions(+), 69 deletions(-) rename ZHTableViewGroup.podspec => ZHTableViewGroupObjc.podspec (92%) diff --git a/Example/ZHTableViewGroup.xcodeproj/project.pbxproj b/Example/ZHTableViewGroup.xcodeproj/project.pbxproj index 6430254..09db15b 100644 --- a/Example/ZHTableViewGroup.xcodeproj/project.pbxproj +++ b/Example/ZHTableViewGroup.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 49A3E2ABDEBD5DA77D02ED2A /* Pods_ZHTableViewGroup_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACD2ED0C6DB511E4A11C24DE /* Pods_ZHTableViewGroup_Example.framework */; }; + 5D0692F31E7F6061008BC142 /* ZHTableViewGroupObjc.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 5D0692F21E7F6061008BC142 /* ZHTableViewGroupObjc.podspec */; }; 5D9BCC821E7D2872001BD760 /* ZHBaseTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9BCC811E7D2872001BD760 /* ZHBaseTableViewCell.m */; }; 5D9BCC851E7D2AB0001BD760 /* ZHCellOneTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9BCC841E7D2AB0001BD760 /* ZHCellOneTableViewCell.m */; }; 5D9BCC881E7D2B09001BD760 /* ZHCellTwoTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9BCC871E7D2B09001BD760 /* ZHCellTwoTableViewCell.m */; }; @@ -44,6 +45,7 @@ /* Begin PBXFileReference section */ 07436A433659DFAD7A803F1A /* Pods_ZHTableViewGroup_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ZHTableViewGroup_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0A4CD91F48BA10BBFFB3CD84 /* Pods-ZHTableViewGroup_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZHTableViewGroup_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ZHTableViewGroup_Tests/Pods-ZHTableViewGroup_Tests.release.xcconfig"; sourceTree = ""; }; + 5D0692F21E7F6061008BC142 /* ZHTableViewGroupObjc.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ZHTableViewGroupObjc.podspec; path = ../ZHTableViewGroupObjc.podspec; sourceTree = ""; }; 5D9BCC801E7D2872001BD760 /* ZHBaseTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHBaseTableViewCell.h; sourceTree = ""; }; 5D9BCC811E7D2872001BD760 /* ZHBaseTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZHBaseTableViewCell.m; sourceTree = ""; }; 5D9BCC831E7D2AB0001BD760 /* ZHCellOneTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHCellOneTableViewCell.h; sourceTree = ""; }; @@ -73,7 +75,6 @@ 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; - 6088A60FFF10A6A695136AF0 /* ZHTableViewGroup.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = ZHTableViewGroup.podspec; path = ../ZHTableViewGroup.podspec; sourceTree = ""; }; 67A8FA6550F7D2AFCBA00DF5 /* Pods-ZHTableViewGroup_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZHTableViewGroup_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-ZHTableViewGroup_Example/Pods-ZHTableViewGroup_Example.release.xcconfig"; sourceTree = ""; }; 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 79FC9CA70C15FE1C388D8A0E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; @@ -222,7 +223,7 @@ 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = { isa = PBXGroup; children = ( - 6088A60FFF10A6A695136AF0 /* ZHTableViewGroup.podspec */, + 5D0692F21E7F6061008BC142 /* ZHTableViewGroupObjc.podspec */, D8B4600E00FBCC66C103D15D /* README.md */, 79FC9CA70C15FE1C388D8A0E /* LICENSE */, ); @@ -313,6 +314,7 @@ buildActionMask = 2147483647; files = ( 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, + 5D0692F31E7F6061008BC142 /* ZHTableViewGroupObjc.podspec in Resources */, 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */, 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, diff --git a/README.md b/README.md index 1da0353..875e500 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,89 @@ -# ZHTableViewGroup +# Swift 版本请移步[这里](https://github.com/josercc/ZHTableViewGroupSwift) -[![CI Status](http://img.shields.io/travis/15038777234/ZHTableViewGroup.svg?style=flat)](https://travis-ci.org/15038777234/ZHTableViewGroup) -[![Version](https://img.shields.io/cocoapods/v/ZHTableViewGroup.svg?style=flat)](http://cocoapods.org/pods/ZHTableViewGroup) -[![License](https://img.shields.io/cocoapods/l/ZHTableViewGroup.svg?style=flat)](http://cocoapods.org/pods/ZHTableViewGroup) -[![Platform](https://img.shields.io/cocoapods/p/ZHTableViewGroup.svg?style=flat)](http://cocoapods.org/pods/ZHTableViewGroup) +# ZHTableViewGroup为 UITableView 而生 -## Example +![](http://olg3v8vew.bkt.clouddn.com/2017-03-16-38.gif) -To run the example project, clone the repo, and run `pod install` from the Example directory first. - -## Requirements - -## Installation - -ZHTableViewGroup is available through [CocoaPods](http://cocoapods.org). To install -it, simply add the following line to your Podfile: +## 怎么安装 ```ruby -<<<<<<< HEAD -pod "ZHTableViewGroup" -======= -pod 'ZHTableViewGroup' -``` - -### 2.直接下载demo拖拽`ZHTableViewSource`到工程里面 - -## 怎么使用 - -### 文件的结构 - -![](https://raw.githubusercontent.com/15038777234/ZHTableViewGroup/master/ZHTableViewDataSource.png) - -在例子里面声明一个变量 - -```objective-c -@property (nonatomic, strong) ZHTableViewDataSource *dataSource; +pod 'ZHTableViewGroupObjc' ``` -在UITableView的代理实现这些方法 - -```objective-c -#pragma mark - UITableViewDataSource -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return self.dataSource.sectionNumber; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - ZHTableViewGroup *group = [self.dataSource groupWithIndex:section]; - return group.rowNumber; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - ZHTableViewGroup *group = [self.dataSource groupWithIndex:indexPath.section]; - UITableViewCell *cell = [group cellWithIndexPath:indexPath]; - return cell; -} - -#pragma mark - UITableViewDelegate -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - ZHTableViewGroup *group = [self.dataSource groupWithIndex:indexPath.section]; - [group didSelectRowAtIndexPath:indexPath]; -} - ->>>>>>> origin/master -``` - -## Author - -15038777234, 15038777234@163.com -## License -ZHTableViewGroup is available under the MIT license. See the LICENSE file for more info. +### 怎么使用 + +1. ### 初始化 ZHTableViewDataSource + + ```objc + @property (nonatomic, strong) ZHTableViewDataSource *dataSource; + self.dataSource = [[ZHTableViewDataSource alloc] initWithTableView:self.tableView]; + ``` + +2. ### 初始化 ZHTableViewGroup + + ```objc + [self.dataSource addGroupWithCompletionHandle:^(ZHTableViewGroup *group) { + } + ``` + +3. ### 初始化 ZHTableViewCell + + ```objc + [group addCellWithCompletionHandle:^(ZHTableViewCell *cell) { + } + ``` + +4. ### 配置 ZHTableViewCell + + ```swift + cell.anyClass = [UITableViewCell class]; + cell.cellNumber = self.cellTexts.count; + cell.height = 44; + cell.identifier = @"UITableViewCellIdentifier"; + [cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) { + NSString *string = self.cellTexts[indexPath.row]; + cell.textLabel.text = string; + if ([self.selectTitles containsObject:string]) { + cell.accessoryType = UITableViewCellAccessoryCheckmark; + } else { + cell.accessoryType = UITableViewCellAccessoryNone; + } + }]; + [cell setDidSelectRowCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) { + NSString *string = self.cellTexts[indexPath.row]; + if ([self.selectTitles containsObject:string]) { + [self.selectTitles removeObject:string]; + } else { + [self.selectTitles addObject:string]; + } + [self.tableView reloadData]; + }]; + + ``` + +5. ### 配置 UITableView的代理 + + ```objc + - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return [ZHTableViewDataSource heightForRowAtDataSource:self.dataSource indexPath:indexPath customHeightCompletionHandle:nil]; + } + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [ZHTableViewDataSource numberOfRowsInSectionWithDataSource:self.dataSource section:section]; + } + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + return [ZHTableViewDataSource cellForRowAtWithDataSource:self.dataSource indexPath:indexPath]; + } + - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + [ZHTableViewDataSource didSelectRowAtWithDataSource:self.dataSource indexPath:indexPath]; + } + + ``` + +### 6 清除配置 + +```objc +[self.dataSource clearData]; +``` \ No newline at end of file diff --git a/ZHTableViewGroup.podspec b/ZHTableViewGroupObjc.podspec similarity index 92% rename from ZHTableViewGroup.podspec rename to ZHTableViewGroupObjc.podspec index a079933..479de0e 100644 --- a/ZHTableViewGroup.podspec +++ b/ZHTableViewGroupObjc.podspec @@ -7,8 +7,8 @@ # Pod::Spec.new do |s| - s.name = 'ZHTableViewGroup' - s.version = '2.0.0' + s.name = 'ZHTableViewGroupObjc' + s.version = '2.0.1' s.summary = 'Manger UITableView DataSource More Cell Style' s.homepage = 'https://github.com/josercc/ZHTableViewGroup'