为什么操作是推送dismissViewControllerAnimated

时间:2014-12-28 03:29:07

标签: ios uinavigationcontroller

我需要解雇带有默认动画的NavigationController,我需要在推送时自定义动画。这就是我正在做的事情:

- (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;
}  

但是操作总是=推,推和解除。这样对吗?我可以检查toViewController而不是检查操作类型,但它会破坏代码。请建议我一些解决方法?

问题创建三分钟,问题一直在解决,一如既往!我只是错误地点击并从关闭按钮而不是控制器创建推送segue。有人可以删除这个问题吗?

1 个答案:

答案 0 :(得分:0)

错误地关闭按钮附加了两个不同的操作。这是在解雇时导致自定义动画。