所以我构建了一个自定义呈现过渡动画,除了视图控制器生命周期方法没有被调用时,一切似乎都很好.
在呈现控制器之前,我使用UIModalPresentationCustom样式将呈现VC保留在视图层次结构中,但是一旦我关闭了呈现的VC,就不会在我的呈现控制器上调用viewWillAppear和viewDidAppear.我错过了一个我需要明确调用以获取这些方法的步骤吗?我知道手动调用这些方法不是正确的解决方案.
这是我的解雇动画代码.我基本上是动画表单覆盖视图,以便在解雇时缩小到集合视图单元格的大小.
- (void)_animateDismissingTransitionWithContext:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UICollectionView *destinationCollectionView = toCollectionViewController.collectionView;
UICollectionViewCell *destinationCollectionViewCell = [self _destinationCellFromContext:transitionContext];
UIView *containerView = transitionContext.containerView;
// Calculate frames
CGRect startFrame = fromEventDetailViewController.detailContainerView.frame;
CGRect endFrame = [destinationCollectionView convertRect:destinationCollectionViewCell.frame toView:containerView];
// Add overlay
UIView *overlayView = [UIView new];
overlayView.backgroundColor = [UIColor overlayBackground];
overlayView.frame = containerView.bounds;
overlayView.alpha = 1.0f;
[containerView addSubview:overlayView];
// Add fake detail container view
UIView *fakeContainerView = [UIView new];
fakeContainerView.backgroundColor = fromEventDetailViewController.detailContainerView.backgroundColor;
fakeContainerView.frame = …Run Code Online (Sandbox Code Playgroud) 我目前有一个基本视图控制器说AVC,它呈现另一个视图控制器说BVC在当前上下文中,如下所示:
let bvc: BVC = sb.instantiateViewControllerWithIdentifier("BVC") as! BVC
bvc.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.presentViewController(bvc, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
然后我在BVC和dismiss中设置一个值,使用相同的值在AVC的viewWillAppear中执行一个函数.但是,我注意到在提示OverCurrentContext时,在关闭时,viewWillAppear不会被调用.
我该如何解决这个问题?我需要一个半透明的呈现视图,因此需要使用OverCurrentContext.
谢谢!