iOS 9中的自定义UIViewController转换错误

时间:2015-12-20 15:07:26

标签: ios uiviewcontroller transitions

我遇到了一个奇怪的错误。我只是使用UIViewControllers的{​​{1}}的iOS自定义转换方法以及UIViewControllerTransitioningDelegate的实现。这一切似乎都很好,直到我做到以下几点:

  1. 打开应用
  2. 使用我的自定义转换提供另一个视图控制器
  3. 旋转到横向
  4. 关闭刚出现的视图控制器
  5. 这就是全部!现在发生的情况如下:我在初始视图控制器的右侧看到一个大的黑条(好像该控制器的视图没有旋转到横向)。

    有趣的是,这只是在iOS 9中出错,在iOS 8中一切似乎都运行得很好。我不知道自定义转换API有什么变化吗?或者这只是一个非常讨厌的iOS 9错误?如果有人能告诉我我做错了什么,或者是否有人可以为我提供解决方法,我真的很感激!

    这些类重现了这个问题:

    UIViewControllerAnimatedTransitioning

    呈现的视图控制器:

    import UIKit
    class ViewController: UIViewController, UIViewControllerTransitioningDelegate {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tap")
            view.addGestureRecognizer(tapGestureRecognizer)
        }
    
        func tap() {
            let controller = ModalViewController()
            controller.transitioningDelegate = self
            presentViewController(controller, animated: true, completion: nil)
        }
    
        func animationControllerForPresentedController(presented: UIViewController,
                                                       presentingController presenting: UIViewController,
                                                       sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
            return Transitioning()
        }
    
        func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
            return Transitioning()
        }
    }
    

    最后是import UIKit class ModalViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.redColor() let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tap") view.addGestureRecognizer(tapGestureRecognizer) } func tap() { dismissViewControllerAnimated(true, completion: nil) } } 实施:

    UIViewControllerAnimatedTransitioning

0 个答案:

没有答案