开发者

How to show the recently added section in UITableView?

I have a table with one section and when I select any row, a new section gets added to the same table, and so on, the number of section to be added is not fixed i.e., two section can be added or three or four as it depends on the data coming from the server. My ques开发者_如何学Ction is how can I show the recently added section when I reload the table?

Thanks-


After reloading the table using [tableView reloadData], use scrollToRowAtIndexPath: method to scroll to a particular section/row. For example,

[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] 
                 atScrollPosition:UITableViewScrollPositionTop 
                         animated:YES];


Update your Array when new data comes from server. and then reload the table.

 - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜