2017-01-09 5 views
0

UITableViewでページングを行う方法(、facebookのようなデータをもっと読み込みます) コード: - の最後のインデックスをチェックする// NSMutableArrayのにcall api iosでuitableviewでページングを行う方法は?

NSArray *resObj = [NSArray alloc] init]; 
NSMutableArray *aMutArray = [NSMutableArray alloc] init]; 
[aMutArray addObject: resObj]; 

を追加したNSArrayにAPIに

+0

を検索:? –

+0

「負荷より遅延ローディングテーブルビューで」あなたが実際に感じている何の問題@Bhavesh Rathod –

+0

https://github.com/MrAlek/AWPagedArray、それはあなたにすべてのものを与えるでしょう。 –

答えて

0

ストア応答データを呼び出していない後にコンテンツの高さ点で最大

-(void)scrollViewDidScroll:(UIScrollView *)scrollView 
{ 
    CGFloat height = scrollView.frame.size.height; 

    CGFloat contentYoffset = scrollView.contentOffset.y; 

    CGFloat distanceFromBottom = scrollView.contentSize.height - contentYoffset; 

    if(distanceFromBottom < height) 
    { 

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

     NSLog(@"end of the table"); 
    } 
} 

スクロールテーブルビュー このコードをcellForItemAtIndexPathに書く

if(lastIndex) 
    { 
     // show load more button 
    } 
0

2つのセクションを取る:最初のセクションの行には表示するアイテムが含まれ、2番目のセクションにはセルがUIActivityIndicatorの行が1つ含まれます。その後

与えられたデリゲートメソッドを実装:このメソッドの呼び出し

func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { 

    if indexPath.section == 1 { 

     let footercell = cell as! ProductFooterCollectionViewCell 
     footercell.loader.startAnimating() 
     fetchSearchProducts() 
    }    
} 
0

テーブルビューのデリゲート表示セルを:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSInteger totalRow = [tableView numberOfRowsInSection:indexPath.section];//first get total rows in that section by current indexPath. 
    if(indexPath.row == totalRow-1) 
    { 
     // Code... 
    } 
} 

はあなたの問題が解決すると思います。

+0

私はこのソリューションを使用しましたが、ループのようにコードが実行されました –

0

テーブルビューセルの最後の行を最初に見つけ出す必要があります。以下は

は、最後の行を見つけるためのコードです:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     NSInteger totalNumberOfRows = [tableView numberOfRowsInSection:indexPath.section]; 

// isLoadMore flage is TRUE when there is more data available. 
     if(indexPath.row == totalNumberOfRows-1 && isLoadMore) 
     { 
      // Code... 
      // Here you need to check if there are some load more data is there from pervious web-service or not. 
    // If there is load more then call web-service and another set of data. 
     } 
    } 

あなたのWebサービスを呼び出すために取得AFNetworkingを使用することができます。

あなたはロジックを取得願っています:)

+0

私はこのソリューションを使用しましたが、ループのようにコードが実行されました –

+0

weillDisplayCellメソッドでflageとcheck条件を設定しました。更新された状態を確認してください。 – Nirmalsinh

関連する問題