0

Is it possible after selecting a cell in the table view and hitting the back button on the following view controller to arrive at the same place in the table? I don't like how it goes back to the top, especially because of the size of my table.

Eduardo
  • 159
  • 8
  • That would generally mean that you're asking it to go to the top. What are you doing in viewWill/DidLoad ? – Wain Jun 20 '13 at 22:06
  • 1
    The default behavior is table view will maintain its position when u push some view controller by tapping on its table cell. There might have been some code in viewWillAppear which is causing the table view to scroll up – ravi Jun 20 '13 at 22:06

2 Answers2

0

You should get the last touched index for the cell, and use

[tableView scrollToRowAtIndexPath:DESIRED_INDEXPATH inSection:indexPath.section] 
         atScrollPosition:UITableViewScrollPositionMiddle animated:NO];

When you return to your previous view controller.

LAMBORGHINI
  • 338
  • 2
  • 13
0

@ravi was right. Normally, the position of cell in table view won't change after pop up from decedent view controller. I'm afraid you setting up the table view in viewWillAppear what cause the table view to be recreated or reloaded everytime the view appear. If there some code inside viewWillAppear, try moving them to view did load.

Vibol
  • 1,158
  • 1
  • 9
  • 23