UIViewControllers
的{{1}}的iOS自定义转换方法以及UIViewControllerTransitioningDelegate
的实现。这一切似乎都很好,直到我做到以下几点:
这就是全部!现在发生的情况如下:我在初始视图控制器的右侧看到一个大的黑条(好像该控制器的视图没有旋转到横向)。
有趣的是,这只是在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