Commit c00e2f4f authored by jz's avatar jz

添加 page

parent eab6bb69
...@@ -98,6 +98,9 @@ ...@@ -98,6 +98,9 @@
/** @brief 获取http数据分页第一页起始位置,默认为0,下一页为startNum+每页的数据条数(默认为10) */ /** @brief 获取http数据分页第一页起始位置,默认为0,下一页为startNum+每页的数据条数(默认为10) */
@property (nonatomic,assign) NSInteger startNum; @property (nonatomic,assign) NSInteger startNum;
/** @brief 获取http数据分页第一页起始位置,默认为1,下一页为pag 1 */
@property (nonatomic,assign) NSInteger page;
/** @brief 获取http数据,每页获取数据(默认为10) */ /** @brief 获取http数据,每页获取数据(默认为10) */
@property (nonatomic,assign) NSInteger count; @property (nonatomic,assign) NSInteger count;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
_dataArray = [[NSMutableArray alloc] init]; _dataArray = [[NSMutableArray alloc] init];
_startNum = 0; _startNum = 0;
_page = 1;
_params = nil; _params = nil;
_count = 10; _count = 10;
_deduplicationDic = [NSMutableDictionary dictionary]; _deduplicationDic = [NSMutableDictionary dictionary];
...@@ -37,7 +38,8 @@ ...@@ -37,7 +38,8 @@
*/ */
- (void)buildParams{ - (void)buildParams{
_params = @{@"start_num":@(self.startNum), _params = @{@"start_num":@(self.startNum),
@"count":@(self.count)}; @"count":@(self.count)
};
} }
- (BOOL)shouldClearDataForResponse:(id)response{ - (BOOL)shouldClearDataForResponse:(id)response{
...@@ -100,6 +102,7 @@ ...@@ -100,6 +102,7 @@
// 因为 clearData 可能会被外部调用,所以 self.startNum = 0 要确认执行,不能少 // 因为 clearData 可能会被外部调用,所以 self.startNum = 0 要确认执行,不能少
self.startNum = 0; self.startNum = 0;
_deleteCount = 0; _deleteCount = 0;
_page = 1;
[self.dataArray removeAllObjects]; [self.dataArray removeAllObjects];
[_deduplicationDic removeAllObjects]; [_deduplicationDic removeAllObjects];
} }
...@@ -107,12 +110,14 @@ ...@@ -107,12 +110,14 @@
- (void)handleHeaderRefreshing - (void)handleHeaderRefreshing
{ {
self.startNum = 0; self.startNum = 0;
self.page = 1;
[self fetchRemoteData]; [self fetchRemoteData];
} }
- (void)handleFooterRereshing - (void)handleFooterRereshing
{ {
self.startNum = self.dataArray.count + _deleteCount; self.startNum = self.dataArray.count + _deleteCount;
self.page+=1;
[self fetchRemoteData]; [self fetchRemoteData];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment