简体   繁体   English

iOS中TableView中的分页问题

[英]Pagination issue in tableview in iOS

I have one tableview.In tableview each page there is 16 data. 我有一个tableview.tableview每页中有16个数据。

For that I am calling one webservice 为此,我打电话给一个webservice

First I am passing Pagin Zero. 首先,我通过零分零。

      [self callAPI:0];

-(void)callAPI:(int)page1{
   [dictParams setObject:[NSString stringWithFormat:@"%d",pagin]  forKey:@"pagin"];
 }

When I scrolldown new data is reloading.But when scroll up to tableview last data is not showing. 当我向下滚动时,新数据正在重新加载。但是当向上滚动至表视图时,最后一个数据未显示。 Here is my code: 这是我的代码:

perPage = 16; 每页= 16;

this is my code for paging 这是我的分页代码

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
    if(self.tblArticle.contentOffset.y >= (self.tblArticle.contentSize.height - self.tblArticle.bounds.size.height))
    {
        if(isPageRefreshing==NO){
            isPageRefreshing=YES;
            [self callAPI:perPage];
        }
    }
      else {
      }
    }

My requirement is first time pagin value is zero.Each time it will be pagin value + 16 我的要求是第一次分页值为零,每次都是分页值+ 16

when I scrollup I am not getting last data in tableview. 当我向上滚动时,我没有在表视图中获取最后一个数据。

Can you help me to find out solution? 您能帮我找出解决方案吗?

You have one array from which you fill tableview. 您有一个数组可以用来填充tableview。 So you have to insert every new data to that array. 因此,您必须将每个新数据插入该数组。

eg, in success response of Api, 例如,在Api的成功回应中,

[yourArr addObjectFromArray:_responseArr] [yourArr addObjectFromArray:_responseArr]

  • then reload tableview 然后重新加载tableview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM