'Why operation is push for dismissViewControllerAnimated

I need to dismiss presented NavigationController with default animation, and I need custom animation on push. Here is what i'm doing:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.delegate = self;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.delegate = nil;
}

- (IBAction)closeButtonTouchUp:(id)sender {
    [self.navigationController dismissViewControllerAnimated:NO completion:nil];
}

- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                   animationControllerForOperation:(UINavigationControllerOperation)operation
                                                fromViewController:(UIViewController *)fromVC
                                                  toViewController:(UIViewController *)toVC {
    if(operation == UINavigationControllerOperationPush) {
        return [TurnAnimationController new];
    }
    return nil;
}  

But operation is always = Push, on push and on dismiss. Is it right? I can check toViewController instead of checking operation type but it will spoil code. Please suggest me some workaround?



Solution 1:[1]

There was two different actions attached to the close button by mistake. That was leading to custom animation while dismiss.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 trickster77777