Unwind Segue from Modal/Popover resulting in Unbalanced calls to begin/end appearance transitions

戏子无情 提交于 2019-12-12 10:38:58

问题


I have the following setup:

Nav Controller -> VC1 -Push--> VC2 -PopOver or Modal Segue--> VC3.

VC3 is unwinding back to VC1.

When the Segue from VC2 to VC3 is PopOver and Modal, the unwind ends in a warning: Unbalanced calls to begin/end appearance transitions for UIViewController"

If the Segue from VC to VC is push, the warning is gone.

Any idea how to get rid of the warning or why its even showing?


回答1:


It's a bug. Ignore it (or, if you want to be a good citizen, file a bug report with Apple).




回答2:


I was able to reproduce your problem and find a solution!

It would be great if the unwind logic would take care of this. Maybe it's a bug, maybe not. Either way, the solution is to make VC2 (The controller that has the popup) the target of the rewind, then wait for it to finish appearing before popping up the nav controller. That ensures the rewind (reverse popup) animation has enough time to finish before moving further back. Even with the animations off, it still has to wait or else you get the error.

Your code for VC2 should be as follows. (Swift)

class VC2: UIViewController {
    private var unwind = false
    @IBAction func unwindToVC1(segue:UIStoryboardSegue) {
        unwind = true
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        if unwind {
            self.navigationController?.popViewControllerAnimated(false)
        }
    }
}


来源:https://stackoverflow.com/questions/32042206/unwind-segue-from-modal-popover-resulting-in-unbalanced-calls-to-begin-end-appea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!