I have a UIViewController subclass that contains a UICollectionView. Selecting a cell presents a new view controller. When I return to the first view controller, the contentOffset of the collection view is reset to CGPointZero.
From my research this seems to be standard behaviour.
I can reset the contentOffset by adding a private property to my view controller subclass, saving the contentOffset in the viewWillDissapear
method and resetting it on the collection view in the viewWillAppear
method.
I would like to know though, is there another way to prevent the scroll view content offset from being reset in the first place (removing the need for an extra property)?
I am targetting iOS7.
The 2nd view controller is presented like this:
[self presentViewController:secondVC animated:YES completion:nil];
And dismissed like this (in the 2nd view controller):
-(void) dismiss
{
[self dismissViewControllerAnimated:YES completion:nil];
}
Edit: After further investigation it appears resetting the contentOffset is not the default behaviour. I haven't figured out why it is happening in my application yet. I am presenting just as have showed in the code above.