create placeholder view for empty data UIViewController/UITableViewController/UICollectionViewController, etc. which needs one line code only!
LPEmptyDataSetter is quite different from other empty dataset third-party lib cause it's base on KVO & runtime, so when use it just set the key for observe. It's very convenient & simple.
- use cocoapods
pod 'LPEmptyDataSetter', '~> 0.0.3'
- manual import
just download lib folder and add into your project
- 1.Firstly custom your placeholder view (any view or subClass of UIView)
// for example, custom placeholder view via UIButton
UIButton *placeholder = [[UIButton alloc] init];
placeholder.frame = CGRectMake(150, 200, 80, 80);
- 2.Add LPEmptyDataSetter to your viewController & view
/**
* target:view controller which placeholder will show inside
* key: observe key name that KVO supports
* view: placeholder view
* frame: placeholder's frame
*/
[LPEmptyDataSetter emptyDataSetWithTarget:self key:@"data" view:placeholder frame:placeholder.frame];
- 3.Additional
placeholder view is under your view controller's control, you can add some event for it so that you can change the placeholder view dynamically, such as sample project show. enjoy it now!
LPEmptyDataSetter is base on KVO, when your observing key value has changed, please set a new variables for your key:
// if your observing key is "data"
NSMutableArray *temp = [NSMutableArray arrayWithArray:"array you fetched"];
//trigger KVO method 1
self.data = temp;
//trigger KVO method 2
[[self mutableArrayValueForKey:@"data"] addObjectsFromArray:"array you fetched"];
it's similar with other data structure such as NSMutableDictionary/NSDictionary or etc.
fix bug of emptyDataSet view back when current view s height narrow
fix a bug causing crash
first commit