万能的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
{
?? ?
}
項目鏈接:http://files.cnblogs.com/files/3yangyue3/超實用的篩選列表.zip
四效果:
多選
單選:
?
轉載于:https://www.cnblogs.com/3yangyue3/p/6394935.html
總結
以上是生活随笔為你收集整理的万能的model数据选择列表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux yum源安装
- 下一篇: pid file