HSSetTableViewController 1.3.1

HSSetTableViewController 1.3.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年11月

hushaohui 维护。



  • hushaohui

最优秀的设置界面和个人信息框架,从分隔线到箭头、标题、详细标题、富文本标题等均可以进行配置和更新,无需判断 indexPath.row,无需纠结如何更新 cell,一行代码就能解决问题!100%的 App 都可以使用!!当前版本已升级到 1.2.2,新增界面分类功能,只需导入 UIViewController+HSSetTableView 到您的 UIViewController 即可。目前支持继承和分类两种实现方式,建议使用分类!

  • 本库优势:
    1. 支持标题、详细文本配置、分割线自定义、箭头自定义、适配不同 App 风格。
    2. 支持 cell 右边文本更新、高度内部计算。支持横竖屏自动适应文本高度。
    3. 支持 cell 右边图片下载,和图片大小以及圆角设置。
    4. 支持标题、详细富文本配置。
    5. 支持自定义 cell 和模型
    6. 支持所有 cell 动态更新内容。

功能

  • [x] 支持最基本 cell(左边标题,右边箭头)
  • [x] 支持右边文本 cell(左边标题,右边文本,文本属性可配置,高度内部自适应)
  • [x] 支持开关 cell(左边标题,右边开关)
  • [x] 支持图片 cell(左边标题,右边图片)
  • [x] 支持 cell 点击以及其他控件事件回调
  • [x] 支持自定义 cell 和 cell 事件
  • [x] 手动代码布局,横竖屏均适配

要求

  • Xcode 7.0 以上

架构

主要

  • HSBaseCellModel
  • HSImageCellModel
  • HSSwitchCellModel
  • HSTitleCellModel
  • HSTextCellModel
  • HSCustomCellModel
  • HSTitleTableViewCell
  • HSBaseTableViewCell
  • HSImageTableViewCell
  • HSSwitchTableViewCell
  • HSTextTableViewCell
  • HSCustomTableViewCell
  • HSSetTableViewMainController

类别

  • NSArray+HSSafeAccess
  • NSBundle+HSImage
  • NSBundle+HSImage
  • UIColor+HSExtension
  • UIView+HSFrame

管理器

  • HSSetTableViewManager
  • UIViewController+HSSetTableView

架构

渲染

如何使用

  • 使用 CocoaPods: 请先安装 Cocoapods,如果版本太老无法找到,请升级 Cocoapods 到最新版本 命令:pod repo update
    • pod 'HSSetTableViewController','~> 1.2.1'
    • 导入头文件:#import <UIViewController+HSSetTableView> 或者 #import <HSSetTableViewController.h>
  • 直接导入:
    • HSSetTableViewController 和 SDWebImage 文件夹拖动到您的项目目录。
    • 导入头文件:#import "UIViewController+HSSetTableView" 或者 #import "HSSetTableViewController.h"
  • 使用方法
    • 分类:您的 UIViewController 只需调用初始化方法 - (void)initSetTableViewConfigure 或者
      - (void)initSetTableViewConfigureWithSectionFooter:(NSArray *)footerViewArry footerHeight:(NSArray *)footerHeightArry

    • 继承:您的 UIViewController 只需继承基类 HSSetTableViewMainController 即可

详情(查看示例程序 HSSetTableViewControllerDemo 获取详细信息)

    //如果是分类,初始化tableView配置。继承则不需要设置
    [self initSetTableViewConfigure];
    
    // 1.创建cell title模型
     HSTitleCellModel *cell1 = [[HSTitleCellModel alloc] initWithTitle:@"相册" actionBlock:^(HSBaseCellModel *model) {
        HSLog(@"点击相册")
    }];
    photo.icon = [UIImage imageNamed:@"MoreMyAlbum"];
    // 2. 创建右边文本显示cell(文本高度自适应)
    HSTextCellModel *cell2 = [[HSTextCellModel alloc] initWithTitle:@"文本更新" detailText:@"加班加到口吐二两鲜血" actionBlock:^(HSBaseCellModel *model) {
        NSLog(@"文本cell点击事件");
    }];
    // 3. 创建右边显示开关cell
    HSSwitchCellModel *cell3 = [[HSSwitchCellModel alloc] initWithTitle:@"开关控制" switchType:YES switchBlock:^(HSBaseCellModel *model, BOOL on) {
        NSLog(@"开关控制 --%d",on);
    }];
    //4.图片cell
    UIImage *placeHolder = [UIImage imageNamed:@"ic_icon_header"];
    HSImageCellModel *cell4 = [[HSImageCellModel alloc] initWithTitle:@"图片" placeholderImage:placeHolder imageUrl:@"http://scimg.jb51.net/170405/2-1F40522332a13.jpg" actionBlock:^(HSBaseCellModel *model) {
        
    } imageBlock:^{
        
    }];
    cell4.controlRightOffset = 40;
    cell4.showArrow = YES;
    
    //5.自定义cell(HSHeaderCellModel必须继承HSCustomCellModel,HSHeaderTableViewCell必须继承HSZhiHuCustomTableViewCell,cellellIdentifier为自定义model绑定的自定义cell,一样的cellellIdentifier说明cell类型是一样,如有不理解请阅读demo)
    __weak __typeof(&*self)weakSelf = self;
    HSHeaderCellModel *header = [[HSHeaderCellModel alloc] initWithCellIdentifier:@"HSHeaderTableViewCell" actionBlock:^(HSBaseCellModel *model) {
        HSHeaderCellModel *hederModel = (HSHeaderCellModel *)model;
        hederModel.text = @"奔跑吧,兄弟";
        [weakSelf updateCellModel:hederModel];
    }];
    header.text = @"天霸动霸tuo";
    header.cellHeight = 100;
    
    //5.添加到数据源
    NSMutableArray *section0 = [NSMutableArray arrayWithObjects:header,cell1,cell2, cell3,cell4,nil];
    [self.hs_dataArry addObject:section0];
    [self.hs_tableView reloadData];
   
   //6.更新每个cellModel属性后,只需要调用完成刷新
   [self updateCellModel:cell4];
    

警告

  • 由于涉及更新问题,请使用 NSMutableArray 添加到数据源,而不是使用 NSArray 存储。
  • 不是直接将 cell 模型放入基类数据源,应先将其放入 NSMutableArray,然后使用 self.hs_dataArry 添加 NSMutableArray。

希望

  • 如果您有任何问题,请通过 issues me 与我联系!
  • 未来将对 cell 扩展和配置进行更新,希望支持更多的主流应用。
  • 希望这能给更多开发者带来便利,我们可以一起讨论。如果您喜欢,请给个 star。