2011-09-09 25 views
0

嗨,我有大約2500條記錄要顯示。所有這些數據都來自MySQL數據庫。這些數據將在類似於iTunes商店的UITableview中一次顯示25個。點擊加載更多,我需要獲取下25條記錄。在UITableView上獲取並顯示更多記錄

注意:沒有圖像只有文本。

有沒有人做過類似的事情?給我示例代碼。

+0

你需要從數據庫中獲取的記錄或將其加載到UITableView中的代碼? –

+1

您必須使用查詢來獲取前25條記錄。因此,對於接下來的25條記錄,在Load Click事件中觸發另一個查詢,然後使用TableView重載。並且每次點擊加載按鈕時都會這樣做。 – DShah

+0

您可以向我發送任何示例代碼鏈接嗎? – vinay

回答

1
first in .h define int row; 

and now in viewDidLoad: row=25; 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
if([your array count]>row) 
return row+1; 
} 
- (UITableViewCell *)tableView:(UITableView *)tableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (indexPath.row<row) 
{ 
    [email protected]"Your Text"; 
} 
else{ 
    [email protected]"Load More"; 
} 
} 
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    if (indexPath.row==row) 
{ 
    row=row+25; 
     [tableView reloadData]; 

    } 

` 希望這將幫助你..

相關問題