嘿, 任何人都可以指導我通過這個我有大約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. Ajax加載更多按鈕
- 4. jQuery加載更多按鈕
- 5. instagram加載更多按鈕
- 6. 爲下一頁加載「更多」按鈕?
- 7. 「在多個表格中加載更多」分頁按鈕。 Django
- 8. 向UITableViewCell添加一個按鈕
- 9. 加載更多的按鈕,將加載更多的帖子
- 10. 一個UITableViewCell中的兩個按鈕
- 11. 添加一個加載的gif到我的加載更多jquery按鈕
- 12. 谷歌加載一個按鈕加載
- 13. 加載更多按鈕使用jQuery
- 14. 動態創建加載更多按鈕
- 15. dryscrape點擊「加載更多按鈕」
- 16. UITableViewCell中的一個按鈕的UIPopoverPresentationController
- 17. 做一個按鈕有多種用途
- 18. 多個按鈕做什麼
- 19. 把兩個按鈕放到一個UITableViewCell
- 20. 在UITableViewCell中的按鈕
- 21. 在UITableViewCell中隱藏按鈕
- 22. 在Android中加載更多按鈕問題
- 23. 在行列表中自定義iOS「加載更多」按鈕
- 24. 在同一位置是否加載多個按鈕
- 25. 使用硒點擊一個'加載更多'按鈕,直到它不存在(Youtube)
- 26. 更改UITableviewCell中的按鈕圖像?
- 27. 做一個按鈕,「斜體」
- 28. 如何將一個按鈕添加到UIScrollView的最後加載更多?
- 29. 閱讀更多UITableViewCell中的UILabel中的按鈕與Swift 3
- 30. 如何在同一個UITableViewCell中使用多個按鈕來實現UITableView?
[「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