-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathKNMultiItemSelector.h
77 lines (59 loc) · 2.28 KB
/
KNMultiItemSelector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// KNMultiItemSelector.h
// KNFBFriendSelectorDemo
//
// Created by Kent Nguyen on 4/6/12.
// Copyright (c) 2012 Kent Nguyen. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KNSelectorItem.h"
typedef enum {
KNSelectorModeNormal,
KNSelectorModeSearch,
KNSelectorModeSelected
} KNSelectorMode;
#pragma mark - MultiItemSelectorDelegate protocol
@protocol KNMultiItemSelectorDelegate <NSObject>
-(void)selectorDidCancelSelection;
-(void)selectorDidFinishSelectionWithItems:(NSArray*)selectedItems;
@optional
-(void)selectorDidSelectItem:(KNSelectorItem*)selectedItem;
-(void)selectorDidDeselectItem:(KNSelectorItem*)selectedItem;
@end
#pragma mark - MultiItemSelector Interface
@interface KNMultiItemSelector : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {
NSMutableArray * items;
NSArray * filteredItems;
NSMutableArray * recentItems;
NSMutableDictionary * indices;
UIButton * normalModeButton;
UIButton * selectedModeButton;
UIImageView * modeIndicatorImageView;
UIView * textFieldWrapper;
KNSelectorMode selectorMode;
id<KNMultiItemSelectorDelegate> delegate;
}
#pragma mark - Public properties
@property (nonatomic, strong) UITableView * tableView;
@property (nonatomic, strong) UITextField * searchTextField;
@property (nonatomic, retain) NSArray * selectedItems;
// Turn on/off table index for items, default to NO
@property (nonatomic) BOOL useTableIndex;
// Turn on/off search field at the top of the list, default to NO, only recommend for large list
@property (nonatomic) BOOL allowSearchControl;
// Turn on/off displaying and storing of recent selected items.
// recentItemStorageKey : If you have multiple selectors in your app, you need to set different storage key for each of the selectors.
// maxNumberOfRecentItems : Defaults to 5.
@property (nonatomic) BOOL useRecentItems;
@property (nonatomic) NSString * recentItemStorageKey;
@property (nonatomic) NSInteger maxNumberOfRecentItems;
-(void)setCurrentSelectedItems;
#pragma mark - Init methods
-(id)initWithItems:(NSArray*)_items
delegate:(id)delegate;
-(id)initWithItems:(NSArray*)_items
preselectedItems:(NSArray*)_preselectedItems
title:(NSString*)_title
placeholderText:(NSString*)_placeholder
delegate:(id)delegateObject;
@end