I'm using the latest iOS 7 animation transitions protocols in order to create a fade transition one a push a view controller; a member of the class PSSpaceDetailViewController
. However, for all other push transitions, I'd like to use the default push animation that UINavigationController
normally provides.
However, having implemented the following code to do exactly that, I'm receiving a strange delayed jarring animation when I push a separate view controller from the aforementioned class. Any ideas why this is happening? I've uploaded a short video showing the animation that I'm trying to describe which will hopefully make it easier to understand the bug: http://d.pr/v/Q754
//PSAnimatngNavigationControllerDelegate.m
+ (instancetype) sharedInstance {
static PSAnimatingNavigationControllerDelegate *shared;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shared = [[PSAnimatingNavigationControllerDelegate alloc] init];
});
return shared;
}
- (PSFadeAnimator *) animator {
if (!_animator) {
_animator = [[PSFadeAnimator alloc] init];
}
return _animator;
}
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
if (operation == UINavigationControllerOperationPush && [toVC isKindOfClass:[PSSpaceDetailViewController class]]) {
return self.animator;
}
return nil;
}
// App Delegate.m
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:notesViewController];
[navigationController setDelegate:[PSAnimatingNavigationControllerDelegate sharedInstance]];
PSSpaceDetailViewController.m
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
PSMatchDetailViewController *matchDetail = [[PSMatchDetailViewController alloc] initWithOriginalSpace:self.space andPotentialLead:self.datasource[indexPath.section][indexPath.row]];
[self.navigationController pushViewController:matchDetail animated:YES];
}
The view controller you're pushing has an nil
background colour, which defaults to clear on iOS 7. Just set it to white or whatever and it'll work.