嘿, 任何人都可以指導我通過這個我有大約15個表中的條目我想另一個15在上一個UITableViewCell中獲得更多的負載。任何人都可以幫我嗎?在uitableviewcell中做一個「加載更多」按鈕?
回答
顯示額外的行中的tableview,在
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return dataRows+1;
}
在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//after setting tableviewcell
if(indexPath.row==dataRows){
[email protected]"Load More Rows";
}
}
在
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==dataRows){
//there you can write code to get next rows
}
}
您需要根據顯示的行更新numberOfRows變量。
編輯:獲取額外的條目後,您可以使用以下方法將它們添加到現有的條目數組中。您的原始數組應該是NSMutableArray
以使用此方法。
[originalEntriesArray addObjectsFromArray:extraEntriesArray];
@SriPriya,添加此line'numberOfRows = [yourEntriesArray count] + 1;'使之更加清晰。 – EmptyStack 2011-05-28 05:48:28
@Simon:你好,我更新了代碼 – SriPriya 2011-05-28 05:53:23
@SriPriya,嗯:) – EmptyStack 2011-05-28 05:56:32
希望這有助於
我花了一個可變數組和一個整型變量,並設置數組整型變量
arr = [[NSMutableArray alloc]initWithObjects:@"Radix",@"Riki", nil]; dataRows = [arr count];
,然後我設定數量的總數根據表格的數據源方法中的整數變量在行中的行數
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return dataRows+1; }
因爲你想在最後一個額外的單元格。
現在就設置表單元的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 靜態的NSString * CellIdentifier = @ 「小區」 的文本;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
//setting the text of the cell as per Mutable array
if (indexPath.row < [arr count]) {
cell.textLabel.text = [arr objectAtIndex:indexPath.row];
}
//setting the text of the extra cell
if (indexPath.row == dataRows) {
cell.textLabel.text = @"more cells";
}
return cell;
}
現在的多個細胞的細胞的命中你想要額外的細胞右所以只需添加
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
方法裏面的代碼,意味着你必須做這樣的事情
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == dataRows) { //code for exra cells please } }
運行您的應用程序來檢查此代碼。
我寫了一個示例項目,做到這一點。從GitHub https://github.com/Abizern/PartialTable
我喜歡使用'beginUpdate'和'endUpdate'更新tableView的部分 – 2012-02-14 16:54:21
下載它,我寫的東西可能會有所幫助:https://github.com/nmondollot/NMPaginator
它封裝了分頁,並與幾乎使用頁面和per_page參數的任何web服務工作。它還具有一個UITableView,可在您向下滾動時自動獲取下一個結果。
- 1. uitableviewcell中的多個按鈕
- 2. 隱藏「加載更多:按鈕在一個懶惰的負載
- 3. instagram加載更多按鈕
- 4. jQuery加載更多按鈕
- 5. Ajax加載更多按鈕
- 6. 爲下一頁加載「更多」按鈕?
- 7. 「在多個表格中加載更多」分頁按鈕。 Django
- 8. 向UiTableViewCell添加一個刪除按鈕
- 9. 向UITableViewCell添加一個按鈕
- 10. 如何在多個DIV按鈕中添加更多Javascript按鈕
- 11. 加載更多的按鈕,將加載更多的帖子
- 12. 添加加載更多文章按鈕
- 13. 一個UITableViewCell中的兩個按鈕
- 14. 添加一個加載的gif到我的加載更多jquery按鈕
- 15. 谷歌加載一個按鈕加載
- 16. 在UITableviewCell中更改按鈕顏色
- 17. 加載更多按鈕使用jQuery
- 18. android recyclerview加載更多按鈕
- 19. 動畫加載更多按鈕ng-repeat
- 20. 動態創建加載更多按鈕
- 21. laravel 4.2分頁加載更多按鈕
- 22. Jquery製表符加載更多按鈕
- 23. 骨幹收集。 「加載更多」按鈕
- 24. android web按鈕加載更多
- 25. dryscrape點擊「加載更多按鈕」
- 26. 如何在本例中更改「加載更多」按鈕
- 27. 在three20 TTThumbsViewController中更改加載更多「按鈕」?
- 28. UITableViewCell中的一個按鈕的UIPopoverPresentationController
- 29. 在android中添加加載更多按鈕到列表視圖
- 30. 做一個按鈕有多種用途
[「Load More」in UITableView](http://stackoverflow.com/questions/4410257/)或[如何實現「Load 25 More」](http://stackoverflow.com/questions/) 2801069 /)或[郵件應用程序加載更多的消息](http://stackoverflow.com/questions/4396464/)或[在iPhone中加載更多記錄](http://stackoverflow.com/questions/4965919/)或[Add加載更多選項到表[視圖](http://stackoverflow.com/questions/5898399/)其中[others](http://stackoverflow.com/search?q=iphone+load+more) – 2011-05-28 07:32:41