Reputation: 543
I have a navigation controller and a scroll view inside it.
When the user hits the "Back" button I would like to animate the scroll view to offset 0, 0 before the view "pop" transition begins.
Whats the best way to do this?
Upvotes: 1
Views: 180
Reputation: 48398
UINavigationBarDelegate
is the delegate class and it implements -navigationBar:shouldPopItem
. Try putting your animation code in there.
Alternately, you can try this
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack. Put animation code here
}
[super viewWillDisappear:animated];
}
Upvotes: 1