前言
本文說明TABAnimated 2.4.0的上拉加載功能
基本原理
在原理上沒有什么新意,和普通的上拉加載原理一致翩剪,基于KVO監(jiān)聽UIScrollView的contentOffSet和contentInset。
不過,在展示上不再是傳統(tǒng)的loading,而是骨架圖檀头。
并且這個骨架圖是基于TABAnimated內(nèi)部的骨架屏生產(chǎn)流程進行制作的,共享緩存熙宇、復(fù)用池鳖擒、配置信息、調(diào)整回調(diào)烫止。
效果圖
上拉加載.gif
使用方式
block形式
[_tableView tab_addPullLoadingActionHandler:^{
// 開發(fā)者在此處進行數(shù)據(jù)請求
// 模擬數(shù)據(jù)請求
[self performSelector:@selector(loadMoreData) withObject:nil afterDelay:0.5];
}];
block形式綁定class蒋荚、height
[_tableView tab_addPullLoadingClass:TestTableViewCell.class viewHeight:100 actionHandler:^{
// 開發(fā)者在此處進行數(shù)據(jù)請求
// 模擬數(shù)據(jù)請求
[self performSelector:@selector(loadMoreData) withObject:nil afterDelay:0.5];
}];
消息傳遞形式
- (void)tab_addPullLoadinTarget:(id)target selector:(SEL)selector;
- (void)tab_addPullLoadingClass:(nonnull Class)pullLoadingClass viewHeight:(CGFloat)viewHeight target:(id)target selector:(SEL)selector;
停止刷新
- (void)tab_stopPullLoading;
永遠停止刷新
- (void)tab_stopPullLoadingNoMoreData;