0

I am implementing UIScroller View into my iPhone App. I have around 50 button in my scrollview and once a user click a button the Action will take him/her to another UIViewController. It is working fine and everything is oki.

But once the user return to the scrollviewController its start from the first button again.

Can i keep the user to the last button he selected before he move to the NextViewController

e.g. If a user selected 35th button and went to another View and once he can back he should be still stay at 35th not the 1st button.

BigAppleBump
  • 1,096
  • 12
  • 26

1 Answers1

3

You can get the current scroll position of the scrollview:

CGPoint scrollingPoint=scrollView.contentOffset;

Save this value in a variable (maybe in your appDelegate) and later restore the scrolling position:

scrollView.contentOffset=scrollingPoint;

Hope this helps.

FD_
  • 12,947
  • 4
  • 35
  • 62
  • thanks alot @FD_ . Adding more to this , tableView here is your UIScrollView. – BigAppleBump Oct 11 '12 at 19:33
  • 1
    Happy I could help. Sorry, I have copied the code from one of my projects, where I use it for UITableviews. I've corrected the answer. – FD_ Oct 11 '12 at 20:36