嘿, 任何人都可以指导我通过这个我有大约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