From 3bd7063cf77c93de0d319b44d4ab35aee4375f61 Mon Sep 17 00:00:00 2001 From: ljh Date: Fri, 8 Jul 2016 10:25:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=9F=E5=BC=83combineReloadData=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82=20=E7=94=B1=E5=A4=96=E9=83=A8=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E5=81=9A=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Private/UITableView+IMYAOPTableView.h | 1 - Classes/Private/UITableView+IMYAOPTableView.m | 37 ++----------------- Classes/TableUtils/IMYAOPTableViewUtils.h | 15 +++++--- Classes/TableUtils/IMYAOPTableViewUtils.m | 11 +++++- README.md | 1 - 5 files changed, 22 insertions(+), 43 deletions(-) diff --git a/Classes/Private/UITableView+IMYAOPTableView.h b/Classes/Private/UITableView+IMYAOPTableView.h index 6475b3a..140ddb4 100644 --- a/Classes/Private/UITableView+IMYAOPTableView.h +++ b/Classes/Private/UITableView+IMYAOPTableView.h @@ -21,7 +21,6 @@ @interface _IMYAOPTableView : UITableView -- (void)aop_realReloadData; - (void)aop_refreshDelegate; - (void)aop_refreshDataSource; ///获取显示中的cell containType => 0:原生cell 1:插入的cell 2:全部cell diff --git a/Classes/Private/UITableView+IMYAOPTableView.m b/Classes/Private/UITableView+IMYAOPTableView.m index d711b3b..25f4e70 100644 --- a/Classes/Private/UITableView+IMYAOPTableView.m +++ b/Classes/Private/UITableView+IMYAOPTableView.m @@ -306,33 +306,9 @@ - (void)aop_layoutSubviews - (void)aop_reloadData { IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils]; - double offsetY = self.contentOffset.y; - NSString* queueKey = [NSString stringWithFormat:@"AOPReloadData_%p", self]; - ///只对下拉刷新 做统一reload处理 - static Class AOPAsyncBlockClass; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - AOPAsyncBlockClass = [NSObject class]; - if (![AOPAsyncBlockClass respondsToSelector:@selector(imy_asyncBlock:onQueue:afterSecond:forKey:)] || - ![AOPAsyncBlockClass respondsToSelector:@selector(imy_cancelBlockForKey:)] || - ![AOPAsyncBlockClass respondsToSelector:@selector(imy_hasAsyncBlockForKey:)]) { - AOPAsyncBlockClass = NULL; - } - }); - if (AOPAsyncBlockClass && aop_utils.combineReloadData && offsetY < 30) { - if ([AOPAsyncBlockClass imy_hasAsyncBlockForKey:queueKey]) { - ///已存在 等它自动刷新就可以了 - return; - } - __weak _IMYAOPTableView* wself = self; - [AOPAsyncBlockClass imy_asyncBlock:^{ - [wself aop_realReloadData]; - } onQueue:dispatch_get_main_queue() afterSecond:0.2 forKey:queueKey]; - } - else { - [AOPAsyncBlockClass imy_cancelBlockForKey:queueKey]; - [self aop_realReloadData]; - } + aop_utils.isUICalling += 1; + [super reloadData]; + aop_utils.isUICalling -= 1; } - (void)aop_refreshDelegate { @@ -358,13 +334,6 @@ - (void)aop_refreshDataSource [super setDataSource:(id)aop_utils]; uiAopUtils.isUICalling -= 1; } -- (void)aop_realReloadData -{ - IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils]; - aop_utils.isUICalling += 1; - [super reloadData]; - aop_utils.isUICalling -= 1; -} - (void)aop_reloadSectionIndexTitles { IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils]; diff --git a/Classes/TableUtils/IMYAOPTableViewUtils.h b/Classes/TableUtils/IMYAOPTableViewUtils.h index 1f32aec..59054af 100644 --- a/Classes/TableUtils/IMYAOPTableViewUtils.h +++ b/Classes/TableUtils/IMYAOPTableViewUtils.h @@ -26,12 +26,6 @@ - (void)insertWithSections:(NSArray*)sections; - (void)insertWithIndexPaths:(NSArray*)indexPaths; -/** - * 是否合并刷新, 如果开启会有个0.2的间隔来进行合并刷新 Default:NO - * 需要开启这个功能,请在podfile中加入 pod 'IMYAsyncBlock' - */ -@property (nonatomic, assign) BOOL combineReloadData; - @end @@ -56,3 +50,12 @@ - (NSIndexSet*)tableSectionsByRealSet:(NSIndexSet*)realSet; @end + + +@interface IMYAOPTableViewUtils (Deprecated_Nonfunctional) +/** + * 已废弃, 由外部自己做合并 + */ +@property BOOL combineReloadData __deprecated_msg("Deprecated"); +@end + diff --git a/Classes/TableUtils/IMYAOPTableViewUtils.m b/Classes/TableUtils/IMYAOPTableViewUtils.m index be00e48..ac7112a 100644 --- a/Classes/TableUtils/IMYAOPTableViewUtils.m +++ b/Classes/TableUtils/IMYAOPTableViewUtils.m @@ -232,7 +232,6 @@ - (void)setupAopClass:(Class)aopClass [self addOverriteMethod:@selector(dequeueReusableCellWithIdentifier:) aopClass:aopClass]; [self addOverriteMethod:@selector(gestureRecognizerShouldBegin:) aopClass:aopClass]; ///add real reload function - [self addOverriteMethod:@selector(aop_realReloadData) aopClass:aopClass]; [self addOverriteMethod:@selector(aop_refreshDataSource) aopClass:aopClass]; [self addOverriteMethod:@selector(aop_refreshDelegate) aopClass:aopClass]; [self addOverriteMethod:@selector(aop_containVisibleCells:) aopClass:aopClass]; @@ -476,4 +475,14 @@ - (BOOL)aop_installed } return NO; } +@end + +@implementation IMYAOPTableViewUtils (Deprecated_Nonfunctional) +- (void)setCombineReloadData:(BOOL)combineReloadData +{ +} +- (BOOL)combineReloadData +{ + return NO; +} @end \ No newline at end of file diff --git a/README.md b/README.md index 4ef2696..0853d21 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ Aspect Oriented Programming For TableView,无业务入侵,无逻辑入侵, * iOS 7+ * ARC only -* 可选:IMYAsyncBlock(https://github.com/li6185377/IMYAsyncBlock) ## 集成