From 8675d8307cfda3252546055d6e2b5821e6ae93d4 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 31 Aug 2015 11:18:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=87=AA=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=B8=8A=E6=8B=89=E5=88=B7=E6=96=B0=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RefreshControl/Manager/XHRefreshControl.h | 10 ++++++++ RefreshControl/Manager/XHRefreshControl.m | 29 +++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/RefreshControl/Manager/XHRefreshControl.h b/RefreshControl/Manager/XHRefreshControl.h index 9df9005..0054e09 100644 --- a/RefreshControl/Manager/XHRefreshControl.h +++ b/RefreshControl/Manager/XHRefreshControl.h @@ -24,6 +24,11 @@ - (void)beginLoadMoreRefreshing; @optional +/** + * 比如有一些页面不需要下拉刷新,仅仅需要一次自动上拉加载更多,然后其他情况就归为手动滑动到底部是上拉加载更多,这个方法就会被调用,前提是需要调用一下startLoadMoreRefreshing + */ +- (void)startLoadMoreForAutoTrigger; + /** * 是否支持下拉刷新 * @@ -172,6 +177,11 @@ */ - (void)endPullDownRefreshing; +/** + * 外部手动启动上拉加载更多的方法,这个方法不需要手动去拖动UIScrollView + */ +- (void)startLoadMoreRefreshing; + /** * 停止上提加载更多的方法 */ diff --git a/RefreshControl/Manager/XHRefreshControl.m b/RefreshControl/Manager/XHRefreshControl.m index 8c5a78e..0e13554 100644 --- a/RefreshControl/Manager/XHRefreshControl.m +++ b/RefreshControl/Manager/XHRefreshControl.m @@ -141,24 +141,29 @@ - (void)endPullDownRefreshing { #pragma mark - Load More Refreshing Method - (void)startLoadMoreRefreshing { - if (self.isLoadMoreRefreshed) { - if (self.loadMoreRefreshedCount < self.autoLoadMoreRefreshedCount && !self.handleNetworkError) { - [self callBeginLoadMoreRefreshing]; - } else { - [self.loadMoreView configuraManualStateWithMessage:[self displayAutoLoadMoreRefreshedMessage]]; - } - } -} - -- (void)callBeginLoadMoreRefreshing { if (self.loadMoreRefreshing) return; + [self callLoadMoreStatus]; + [self.delegate startLoadMoreForAutoTrigger]; +} + +- (void)callLoadMoreStatus { self.loadMoreRefreshing = YES; self.handleNetworkError = NO; self.loadMoreRefreshedCount ++; self.refreshState = XHRefreshStateLoading; [self.loadMoreView startLoading]; - [self.delegate beginLoadMoreRefreshing]; +} + +- (void)callBeginLoadMoreRefreshing { + if (self.loadMoreRefreshing) + return; + if (self.loadMoreRefreshedCount < self.autoLoadMoreRefreshedCount && !self.handleNetworkError) { + [self callLoadMoreStatus]; + [self.delegate beginLoadMoreRefreshing]; + } else { + [self.loadMoreView configuraManualStateWithMessage:[self displayAutoLoadMoreRefreshedMessage]]; + } } - (void)endLoadMoreRefresing { @@ -621,7 +626,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N //判断是否滚动到底部 if(((y - size.height) + self.preloadValue) > kXHLoadMoreViewHeight && self.refreshState != XHRefreshStateLoading && self.isLoadMoreRefreshed && !self.loadMoreRefreshing && !self.noMoreDataForLoaded) { - [self startLoadMoreRefreshing]; + [self callBeginLoadMoreRefreshing]; } } }