Is it possible to push a View Controller with a completion block?

user3300062 picture user3300062 · Feb 13, 2014 · Viewed 12.6k times · Source

UINavigationController's documentation contains no pushViewController methods with a completion: parameter.

Answer

justMartin picture justMartin · May 21, 2014

The better solution would be wrapping the push animation by an CATransaction and set the completionBlock. There's no need to deal with timings.

[CATransaction begin];
[CATransaction setCompletionBlock:^{
    //whatever you want to do after the push
}];
[[self navigationController] pushViewController:viewController animated:YES];
[CATransaction commit];