开发者

iPhone: How do I add a 'next 25' like at the bottom of the screen in the app store app?

I've got a UITableView and I want to have a 'next 25' feature like in the app store app.

However, I've no idea what control they use and 开发者_开发知识库how to develop it.

Can someone shed light on it and give me as much info a possible ?


What they do is create another cell, with a button in it. When that button is tapped, some method is fired which goes out and fetches more data, and then adds it to the tableview's data source, and reloads the table.

This "load more" cell never relies on the data source (it gets added without asking the DS for anything, remember that), instead, special case handling code in tableView:cellForRowAtIndexPath: is added to check if we're at the bottom of the tableview, and then return the custom cell. So when we reload the tableview after adding the new items to the data source, the tableview gets bigger, and the button goes away from that position, and gets added to the bottom when we get to the new bottom. :)


The first half of the answer above is correct. The second half (using reloadData) isn't the best way to do it.

Once you have your new data, you should call insertRowsAtIndexPaths:withRowAnimation: on your table view. That tells the table view that you've added a bunch of new rows and lets it animate the addition of the new rows. For example, you might pass UITableViewRowAnimationFade or UITableViewRowAnimationTop. It's also more efficient, because the table view doesn't have to reload and redraw the rows that are already in the table.

Also, take a look at some of the videos on table views from the 2010 WWDC (you can find them at http://developer.apple.com/iphone and then scroll to the bottom). They've got lots of great stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜