0
-(void)fetchNewsFeeds:(NSInteger)off_Set withLimit:(NSInteger)limitFeeds
{
    [[FriendflyLoader sharedLoader] show];
    NSLog(@"NewsFeed Count Before Call : - %lu",(unsigned long)newsFeedsArray.count);

     NSString *offcet=[NSString stringWithFormat:@"%ld",(long)off_Set];
    NSString *New_limit =@"20";//[NSString stringWithFormat:@"%ld",(long)limitFeeds];

    [[Model sharedInstance] fetchnewsFeedsFiltered:isFiltered fetchAllGroups:fetchAllGroups fetchUnassigned:fetchUnassigned fetchGroups:fetchGroups fetchAllContacts:fetchAllContacts fetchFriendFlyContacts:fetchFriendFlyContacts withoffset:offcet andlimit:New_limit withViewAllPost:viewAllPost includeNetworks:networks onCompletion:^(BOOL success, NSArray *feeds) {
        if(success)
        {
            isLoadMore = true;

            newsFeedsArray = [NSMutableArray arrayWithArray:feeds];
            filteredArray = [NSMutableArray arrayWithArray:newsFeedsArray];
            NSLog(@"NewsFeed Count After Call : - %lu",(unsigned long)newsFeedsArray.count);
            newsFeedTableview.delegate = self;
            newsFeedTableview.dataSource = self;
            [newsFeedTableview needsUpdateConstraints];
            [newsFeedTableview reloadData];
            [[FriendflyLoader sharedLoader] hide];
            [newsFeedTableview needsUpdateConstraints];
            [refresh endRefreshing];

        }
        else{
            NSLog(@"Api Not Call_______");
        }
    }];
}


//Call Api using willDisplayCell but First time okay but second time constant Call runing like loop
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    NSInteger lastSectionIndex = [tableView numberOfSections] - 1;

    NSLog(@"section = %ld && Last Count = %ld && isLoadMore = %@",indexPath.section,lastSectionIndex,isLoadMore ? @"True":@"False");


     if (indexPath.section == lastSectionIndex && indexPath.row == 0 && isLoadMore ) {

 [self fetchNewsFeeds:(filteredArray.count + 1)  withLimit:20];

    }


}
Apurv
  • 16,578
  • 8
  • 47
  • 66
Bhavesh Rathod
  • 158
  • 1
  • 5

1 Answers1

0

Please see this and this post.

// ... setting up the table view here ...
self.tableView.delegate = self;
// ...

// Somewhere in your implementation file:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@"Will begin dragging");
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"Did Scroll");
}

You can get the offset value from here

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    NSIndexPath *firstVisibleIndexPath = [[self.tableView indexPathsForVisibleRows] objectAtIndex:0];
    NSLog(@"first visible cell's section: %i, row: %i", firstVisibleIndexPath.section, firstVisibleIndexPath.row);
}
Community
  • 1
  • 1
Shuvo Joseph
  • 824
  • 1
  • 10
  • 18