万能的model数据选择列表

一.测试用例Person类说明:

头文件:

#import <Foundation/Foundation.h>

 

@interface Person : NSObject

@property(nonatomic,copy)NSString *name;

@property(nonatomic,copy)NSString *ID;

@property(nonatomic,assign)NSInteger age;

 

+(NSArray *)testArray;

@end

实现文件:

#import "Person.h"

 

@implementation Person

+(NSArray *)testArray

{

    NSMutableArray *mutableArray=[[NSMutableArray alloc] init];

    for (NSInteger i=0; i<100; i++)

    {

        Person *person=[[Person alloc] init];

        person.name=[NSString stringWithFormat:@"xxx%ld",i];

        person.ID=[NSString stringWithFormat:@"1207020100%ld",i];

        [mutableArray addObject:person];

    }

    return mutableArray;

}

@end

二 使用方法:

1.初始化:

-(YYSelectedTableView *)selectedTableView

{

    if (!_selectedTableView)

    {

        _selectedTableView=[[YYSelectedTableView alloc] init];

        _selectedTableView.dataArray=[Person testArray];//把要显示的Model数据数组赋值给dataArray属性

        _selectedTableView.selectedTableViewStyle=YYSelectedTableViewMultiselect;//设置为多选选模式

        [_selectedTableView installSearchKey:@[@"name"]];//指定搜索时通过哪些字段来找到你要搜索的数据

        _selectedTableView.showKey=@"name";//列表上要显示的字段

    }

    return _selectedTableView;

}

2.显示

    /**

     显示列表框

     **/

    [self.selectedTableView show:self.view];

3.回调

/**

 选择完成时的回调(返回model对象)

 **/

-(void)selectedTableViewSelected:(NSArray *)array andSelf:(YYSelectedTableView *)view

{

    

}

项目链接:https://files.cnblogs.com/files/3yangyue3/超实用的筛选列表.zip

四效果:

多选

单选:

 

posted @ 2017-02-13 18:12  杨悦··  阅读(186)  评论(0编辑  收藏  举报