【问题标题】:animationControllerForOperation not called after app goes to background应用程序进入后台后未调用 animationControllerForOperation
【发布时间】:2014-10-27 23:52:18
【问题描述】:

我有一个使用 UINavigationControllerDelegate 的带有自定义导航推送转换的视图控制器。当您启动动画、按下后退按钮等时,一切都会完美运行。

但是,如果您将视图控制器压入堆栈,将应用程序置于后台,返回,然后按回,则不会调用委托方法 animationControllerForOperation。在调试过程中,我已经验证当我们将应用程序返回到前台时 self.navigationController.delegate 仍然正确设置,但委托回调从未被命中。有什么想法吗?

 //presenting vc
 - (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                              animationControllerForOperation:(UINavigationControllerOperation)operation
                                           fromViewController:(UIViewController*)fromVC
                                             toViewController:(UIViewController*)toVC
{
    if (operation == UINavigationControllerOperationPush) {
        _animationObject = [LVDashboardExplainerAnimation new];
        _animationObject.presenting = YES;
        return _animationObject;
    } else if (operation == UINavigationControllerOperationPop) {
        _animationObject.presenting = NO;
        return _animationObject;
    }
    return nil;
}

//other VC
- (void)headerTapped {
    self.navigationController.delegate = _navigationDelegate; //correct object
    [self.navigationController popViewControllerAnimated:YES];
}

【问题讨论】:

    标签: ios objective-c uinavigationcontroller uiviewanimationtransition


    【解决方案1】:

    问题源于在应用从后台返回时手动调用 viewWillAppear:animated。通过调用它,导航委托将调用 willShowViewController:animated: 但不会调用 navigationController:animationControllerForOperation: 或 didShowViewController:animated:

    出于某种原因,强行调用 viewWillAppear 会导致整个事情发生。即使我们考虑到这一点并将导航委托设置为 nil,然后返回正确的对象,该功能也无法正常工作。我猜这是 SDK 中的一个错误,但现在我们删除了对 viewWillAppear 的强制调用。

    【讨论】:

      猜你喜欢
      • 2013-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 1970-01-01
      • 2014-07-07
      相关资源
      最近更新 更多