QViet
QViet

Reputation: 307

UITableView add row at top

I have a Uitableview with loading mode like that, When user scroll to item 5 it'll auto load 10 item and add in the top of label. My problem is when add like that, current cell move down 10 item, it's bad look.

Can we add cell at top UITableView but current cell not move up or down until user scroll.

Upvotes: 3

Views: 3772

Answers (2)

Walt Sellers
Walt Sellers

Reputation: 3939

Just posted an answer with code snippets here

Keep uitableview static when inserting rows at the top

Basically:

  • Save the scroll offset where you would have called beginUpdate:.
  • In place of calls to InsertCell you add the cell's height to the saved offset.
  • Where you would have called endUpdate:, call reloadData, then scroll by the saved offset with NO animation.

Upvotes: 0

Chance Hudson
Chance Hudson

Reputation: 2859

What you could do is insert your rows, then use scrollToRowAtIndexPath:atScrollPosition:animated: method to scroll to the row you would like to display. More info here.

Upvotes: 1

Related Questions