使用UIModalPresentationStyle.OverFullScreen关闭会导致黑屏

时间:2016-04-01 23:14:47

标签: ios swift

我有一个视图控制器(VCA),它以模态方式呈现另一个视图控制器VCB

presentViewController(VCB, animated: true, completion: nil)

如果VCBmodalPresentationStyle = .OverFullScreen(同样适用于.OverCurrentContext),为什么何时被解雇:

dismissViewControllerAnimated(true, completion: nil)
转换完成后,

执行以下代码会导致VCA变黑?

func animateTransition(transitionContext: UIViewControllerContextTransitioning) {

    let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewContrllerKey)!
    let fromVc = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
    var containerView = transitionContext.containerView()!

    if presenting {
        toVC.view.alpha = 0
        containerView.insertSubview(toVC.view, aboveSubview: fromVC.view)
    } else {
        containerView.insertSubview(toVC.view, belowSubview: fromVC.view)
    }

    UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0.0, options: [.CurveEaseInOut], animations: {
        if self.presenting {
            self.toVC.view.alpha = 1
        } else {
            self.fromVC.view.alpha = 0
        }
        } , completion: { finished in
            self.transitionContext.completeTransition(true)
    })
}

在执行上述行之前,有没有办法解决这个没有删除行containerView.insertSubview(toVC.view, belowSubview: fromVC.view) 检查fromVC.modalPresentationStyle的值?即我可以在VCAVCB的初始化程序中设置一些参数吗?

非常感谢您的帮助。

0 个答案:

没有答案