iOS 8 unwind segue leads to orientation error

时间:2015-08-07 02:49:45

标签: ios iphone xcode swift

I have a View contoller A(VCA) that segues to View Controller B(VCB) modally. VCB has a button that unwinds back to VCA. The problem I am facing is that If I segue from VCA(portrait mode) to VCB and then change the orientation of VCB to landscape and then tap button to unwind, The VCA appears in portrait mode with half of the right screen all black. enter image description here

1 个答案:

答案 0 :(得分:0)

如果您使用的是自定义动画视图控制器转换,请尝试设置要转换到的视图的框架:

extension CustomTransition: UIViewControllerAnimatedTransitioning {

    func animateTransition(context: UIViewControllerContextTransitioning) {
        guard
            let containerView = context.containerView(),
            let fromView = context.viewForKey(UITransitionContextFromViewKey),
            let toView = context.viewForKey(UITransitionContextToViewKey)
        else {
            return context.completeTransition(!context.transitionWasCancelled())
        }

        // This is the important line
        toView.frame = fromView.frame

        // Do your custom animations
    }
}