Skip to content

Commit

Permalink
更新了说明文档
Browse files Browse the repository at this point in the history
  • Loading branch information
15038777234 committed Mar 20, 2017
1 parent ce320ec commit b6070ac
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 69 deletions.
6 changes: 4 additions & 2 deletions Example/ZHTableViewGroup.xcodeproj/project.pbxproj
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
5D0692F21E7F6061008BC142 /* ZHTableViewGroupObjc.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ZHTableViewGroupObjc.podspec; path = ../ZHTableViewGroupObjc.podspec; sourceTree = "<group>"; };
5D9BCC801E7D2872001BD760 /* ZHBaseTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHBaseTableViewCell.h; sourceTree = "<group>"; };
5D9BCC811E7D2872001BD760 /* ZHBaseTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZHBaseTableViewCell.m; sourceTree = "<group>"; };
5D9BCC831E7D2AB0001BD760 /* ZHCellOneTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHCellOneTableViewCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -73,7 +75,6 @@
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
6088A60FFF10A6A695136AF0 /* ZHTableViewGroup.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = ZHTableViewGroup.podspec; path = ../ZHTableViewGroup.podspec; sourceTree = "<group>"; };
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 = "<group>"; };
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
79FC9CA70C15FE1C388D8A0E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
Expand Down Expand Up @@ -222,7 +223,7 @@
60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = {
isa = PBXGroup;
children = (
6088A60FFF10A6A695136AF0 /* ZHTableViewGroup.podspec */,
5D0692F21E7F6061008BC142 /* ZHTableViewGroupObjc.podspec */,
D8B4600E00FBCC66C103D15D /* README.md */,
79FC9CA70C15FE1C388D8A0E /* LICENSE */,
);
Expand Down Expand Up @@ -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 */,
Expand Down
145 changes: 80 additions & 65 deletions 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];
```
4 changes: 2 additions & 2 deletions ZHTableViewGroup.podspec → ZHTableViewGroupObjc.podspec
Expand Up @@ -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'
Expand Down

0 comments on commit b6070ac

Please sign in to comment.