UItableView load data on scroll

后端 未结 6 733
予麋鹿
予麋鹿 2020-12-24 03:42

In my app I am getting the data from the web-service and I have to display it in UITableView. But the condition here is I have to display only 10 records initially,then once

6条回答
  •  半阙折子戏
    2020-12-24 04:14

     - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger lastSectionIndex = [tableView numberOfSections] - 1;
    NSInteger lastRowIndex = [tableView numberOfRowsInSection:lastSectionIndex] - 1;
    if ((indexPath.section == lastSectionIndex) && (indexPath.row == lastRowIndex)) {
        i = i +10;
        NSString *unescaped = mySearchBar.text;
        NSString *escapedString = [unescaped stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
        [PServiceAPI searchKeyWord:escapedString withOffSet:i Handler:^(NSArray *results, NSError *error) {
            if (error == nil) {
                [arBase addObjectsFromArray:results];
                [myTableView2 reloadData];
    
            }
        }];
    
      }
    }
    

提交回复
热议问题