vgr
vgr

Reputation: 543

Nav "Back" button pause in order to do a quick animation before pop

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

Answers (1)

PengOne
PengOne

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

Related Questions