2013-05-28 34 views

回答

1

我假設您將自定義單元添加到表視圖的底部以指示當前數據集的結尾。當您創建該單元格時,請將其tag屬性設置爲您之前定義的有意義的常量,如END_OF_TABLE_CELL

然後使用委託方法tableView:willDisplayCell:forRowAtIndexPath檢查要顯示的單元格是否是您的自定義單元格,並觸發表格數據源的重新加載。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
//check your cell's tag 
if (cell.tag == END_OF_TABLE_CELL) { 
     //Call your custom method to fetch more data and reload the table 
    // You should also remove this custom cell from the table and add one at the bottom 
} 
} 

這樣,您將有自我刷新每當用戶向下滾動到足以使自定義單元格進入視野的表。

祝你好運!

+0

我做了這個,它的工作就像一個魅力。這種方法的更深入的教程:http://nsscreencast.com/episodes/8-automatic-uitableview-paging。 – niaher

相關問題