XQMultistageTableView - iOS多级列表

可以实现带头像带子节点,也可实现不带头像的子节点

CocoaPods

pod 'XQMultistageTableView', '~> 1.0.0'

通过  XQNode设置对应的节点

typedef enum{
    XQNodeContentTypeSuper, // 父节点
    XQNodeContentTypeSub,  // 子节点
}XQNodeContentType;

@interface XQNode : NSObject

#pragma 共同拥有
/// 节点名称
@property(nonatomic, copy) NSString *title;

/// 父节点的id,如果为-1表示该节点为根节点
@property (nonatomic , retain) NSNumber *parentId;

/// 本节点的id
@property (nonatomic , retain) NSNumber *nodeId;

/// 该节点的深度
@property (nonatomic , assign) int depth;

/// 使用者id
@property (nonatomic , retain) NSNumber *userId;

/// 内容类型
@property (nonatomic , assign) XQNodeContentType contentType;

/// 图片路径
@property (nonatomic , copy) NSString *imagePath;

#pragma Super
/// 子节点列表
@property (nonatomic, strong) NSMutableArray *subItems;

/// 该节点是否处于展开状态
@property (nonatomic , assign) BOOL isExpand;

@end

将创建好的数据源交给XQMultistageAdapter管理

_adapter = [[XQMultistageAdapter alloc] init];
_adapter.delegate = self;
_adapter.multistageData = self.data;
UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
tableView.dataSource = _adapter;
tableView.delegate = _adapter;
[self.view addSubview:tableView];

XQMultistageAdapterDelegate

- (void)multistageAdapter:(XQMultistageAdapter *) adapter node:(XQNode *) node didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

点击事件

XQMultistageCellDelegate

// 子 自己决定怎么显示图片
- (void)multistageCell:(XQMultistageCell *) cell imageView:(UIImageView *) imageView forRowAtNode:(XQNode *) node;

// 子 自己决定与父标题间距
- (CGFloat)multistageCellSuperPidding:(XQMultistageCell *) cell;

视图控制器

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    _adapter = [[XQMultistageAdapter alloc] init];
    _adapter.delegate = self;
    _adapter.multistageData = self.data;
    UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    tableView.dataSource = _adapter;
    tableView.delegate = _adapter;
    [self.view addSubview:tableView];
}

#pragma mark - XQMultistageCellDelegate

-(CGFloat)multistageCellSuperPidding:(XQMultistageCell *)cell
{
    return 30;
}

-(void)multistageCell:(XQMultistageCell *)cell imageView:(UIImageView *)imageView forRowAtNode:(XQNode *)node
{
    if (node.imagePath.length) {
        imageView.image = [UIImage imageNamed:node.imagePath];
    }
}


Github地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值