我使用下面显示的代码以无缝滑动方式呈现新的 View Controller 。实际的动画效果很好,但是当动画结束时,所有的 View 都消失了,我只剩下一个空白屏幕。控制台中显示错误
“对 < Rocket_Game18GameViewController: 0x155e288f0 > 开始/结束外观转换的不平衡调用”
class SlideRightToLeft: UIStoryboardSegue {
override func perform() {
var sourceVC:UIViewController = self.sourceViewController as UIViewController
var destVC:UIViewController = self.destinationViewController as UIViewController
let sourceVCFrame = sourceVC.view.frame
let width = destVC.view.frame.size.width
sourceVC.view.addSubview(destVC.view)
destVC.view.frame = CGRectOffset(sourceVCFrame, width, 0)
UIView.animateWithDuration(1.5, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
sourceVC.view.frame = CGRectOffset(sourceVCFrame, -width, 0)
}, completion: {
finished in
destVC.view.removeFromSuperview()
sourceVC.presentViewController(destVC, animated: false, completion: nil)
})
}
}
请询问您是否需要更多信息,谢谢!
最佳答案
我现在已经通过将其他人的 objective-c 代码转换为 swift 来弄清楚我做错了什么。事实证明,我的整个自定义动画想法都是错误的,当 iOS7 发布时,他们改变了它的实现方式。这是我找到解决方案的博客链接,以防其他人想看到它
关于ios - 自定义转换给出 "Unbalanced calls to begin/end appearance transitions"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24918075/