• Stars
    star
    327
  • Rank 128,686 (Top 3 %)
  • Language
    Objective-C
  • Created almost 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A comboBox contained three kinds of style

MMComboBox.png

Features

  • 支持单层的单选和多选
  • 支持两层联动筛选
  • 支持三层联动筛选
  • 支持混合模式的单选和多选

Requirements

  • iOS 7.0 or later

Installation

cloning the MMComboBox folder into your repository

Rrchitecture(工程结构图)

结构图.png

Example code

1.导入头文件:

#import "MMComBoBox.h"

1.初始化视图:

 MMComBoBoxView *view = [[MMComBoBoxView alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, 40)];
    view.dataSource = self;
    view.delegate = self;
    [self.view addSubview:view];
    [view reload];

2.通过datasource协议将数据传给MMComBoBoxView,你可以联想UITableView数据驱动方式就可以了。

#pragma mark - MMComBoBoxViewDataSource
- (NSUInteger)numberOfColumnsIncomBoBoxView :(MMComBoBoxView *)comBoBoxView {
    return self.mutableArray.count;
}

- (MMItem *)comBoBoxView:(MMComBoBoxView *)comBoBoxView infomationForColumn:(NSUInteger)column {
    return self.mutableArray[column];
}

3.我们会通过MMComBoBoxViewDelegate协议把选中的路径回调出来,这里我们选择回调存储路径的数组的本质是在于可能开发人员上传的不止是title,可能还有对应的code等一系列的字段。这样方便扩展。

#pragma mark - MMComBoBoxViewDelegate
- (void)comBoBoxView:(MMComBoBoxView *)comBoBoxViewd didSelectedItemsPackagingInArray:(NSArray *)array atIndex:(NSUInteger)index;

Example gif

example.gif