Latest 2.0.6
Homepage https://github.com/Haidora/HaidoraTableViewManager
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit, Foundation
Authors

Version
License
Platform

UITableViewDataSource UITableViewDelegate的封装.

UITableView

//1.创建TableView和数据
UITableView *tableView = [[UITableView alloc]init];
tableView.dataSource = self;
tableView.delegate = self;
NSArray *datas = @[@"1",@"2",@"3"];

//2.实现相关协议
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return datas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = ...;
    cell.textLabel.text = datas[indexPath.row];
    return cell;
}

HaidoraTableViewManager

Objc

//1.创建TableView和数据
UITableView *tableView = [[UITableView alloc]init];
NSArray *datas = @[@"1",@"2",@"3"];

//2.创建manager
HDTableViewManager *manager = [HDTableViewManager manager];
//配置cell,类似tableView:numberOfRowsInSection:
manager.cellConfigure = ^(UITableViewCell *cell, id itemData, NSIndexPath *indexPath) {
          cell.textLabel.text =
              [NSString stringWithFormat:@"index-%@-%@", @(indexPath.section), @(indexPath.row)];
          cell.detailTextLabel.text =
              [NSString stringWithFormat:@"subIndex-%@-%@", @(indexPath.section), @(indexPath.row)];
        };
HDTableViewSection *section = [HDTableViewSection section];
[section.items addObjectsFromArray:datas];

tableView.dataSource = manager;
tableView.delegate = manager;

Swift

//Swift和OC版本差异性不大,唯一需要注意的是,OC中通过NSStringFromClass([self class])获取类名然后去加载相关的nib。由于在Swift中获取类名会不一样,所以需要手动指定资源
class ViewControllerCell: UITableViewCell {
    override class func hd_nibName() -> String {
    //nib文件的名称
        return "ViewControllerCell"
    }

    override class func hd_cellIdentifier() -> String {
    //cell复用id
    return "ViewControllerCell"
    }
}

Installation

HaidoraTableViewManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "HaidoraTableViewManager"
  • iOS 7.0+
  • Objc/Swift

Inspired by these projects:

Author

mrdaios, [email protected]

License

HaidoraTableViewManager is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HaidoraTableViewManager",
    "version": "2.0.6",
    "summary": "a wrapper for UITableView.",
    "description": "a wrapper for UITableViewDatasource and UITableViewDelegate.",
    "homepage": "https://github.com/Haidora/HaidoraTableViewManager",
    "license": "MIT",
    "authors": {
        "mrdaios": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Haidora/HaidoraTableViewManager.git",
        "tag": "2.0.6"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ]
}

Pin It on Pinterest

Share This