xcode 在 TableView 中加载更多选项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6936968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Load More Option In TableView?
提问by user755278
I need to implement Load More Option in tableView . I had received data from the web services in XML and i had parsed the XML files through the XML Api URLs and display the data in the UITableView.
我需要在 tableView 中实现 Load More Option 。我从 XML 格式的 Web 服务接收数据,我通过 XML Api URL 解析了 XML 文件并在 UITableView 中显示数据。
API URL is like:-
API URL 是这样的:-
"%d" this is the place holder for the Page No. there are 10 pages from (1 to 10) and each page has 15 News which i display on UITableView.
“%d”这是页码的占位符。从(1 到 10)有 10 页,每页有 15 个新闻,我在 UITableView 上显示。
Now I want "LoadMore" option in the table view for when user click on load more option then value of "%d"place holder is changing from 1 to 2 and so on and load the next 15 news of page 2 on the tableView with the preexist news of page 1 and again showing the load more option for next pages.
现在我想在表格视图中使用“LoadMore”选项,当用户点击加载更多选项时,“%d”占位符的值从 1 变为 2 等等,然后在 tableView 上加载第 2 页的下 15 个新闻第 1 页的预先存在的新闻,并再次显示下一页的加载更多选项。
Can any one suggest me the way to implement the "LoadMore" option in the UITableView.
任何人都可以建议我在 UITableView 中实现“LoadMore”选项的方法。
Thanks In Advance.
提前致谢。
回答by Karthikeyan
Instead use Load More Button in Footer View of tableview & reload tableview for every page count.
而是在 tableview 的页脚视图中使用加载更多按钮并为每个页面计数重新加载 tableview。
or Try this Links
或试试这个链接
https://github.com/sishen/LoadMoreTableFooterView
https://github.com/sishen/LoadMoreTableFooterView
回答by fncap
Or try the three20 framework
或者试试three20框架
https://github.com/facebook/three20
https://github.com/facebook/three20
There is a class named TTTableViewController that implements Load more button.
有一个名为 TTTableViewController 的类,它实现了加载更多按钮。
回答by Hariprasad.J
Just add a button in 11 th cell by using indexPath.row
只需使用 indexPath.row 在第 11 个单元格中添加一个按钮
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
if (indexPath.row == 11)
{
UIButton *btnMore = [[UIButton alloc]initWithFrame:CGRectZero];
btnMore.backgroundColor=[UIColor clearColor];
btnMore.font=[UIFont fontWithName:@"Arial" size:15.0];
[btnMore setFrame:CGRectMake(10,10,100,44)];
[cell addSubview:btnMore];
[btnMore release];
return cell;
}
}
回答by Baby Groot
When LoadMore is clicked parse xml with next %d value and add them in your array and reload your table [tablename reloaddata];
单击 LoadMore 时,使用下一个 %d 值解析 xml 并将它们添加到您的数组中并重新加载您的表 [tablename reloaddata];
回答by Derek Li
I think use face book's "pull down to refresh" way is the most user-friendly approach, only different it yours will be "pull up to load more".
我认为使用脸书的“下拉刷新”方式是最人性化的方法,唯一不同的是你的“上拉加载更多”。

