【发布时间】:2014-11-24 01:30:28
【问题描述】:
示例项目: http://cl.ly/1C0N0E0f3n2P
我正在尝试在 iOS 8 中创建到视图控制器的自定义转换。我正在使用 UIPresentationController 以及实现 UIViewControllerAnimatedTransitioning 的 NSObject 子类,基本上遵循 this tutorial。
我还想在视图控制器出现时隐藏状态栏,但我不知道在这个范例中我应该在哪里执行此操作。
每当我尝试在UIPresentationController 子类中调用presentingViewController 上的方法,或者使用NSObject 子类中的键时,我总是会崩溃,这让我相信我不应该调用方法关于这些?
示例示例:
class CustomPresentationController: UIPresentationController {
override func presentationTransitionWillBegin() {
// Following line causes crash
(presentingViewController as ViewController).testFunction()
let darkOverlayView = UIView(frame: presentingViewController.view.bounds)
darkOverlayView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
containerView.addSubview(darkOverlayView)
}
}
那么我到底在哪里隐藏状态栏?我不想在调用presentViewController 的同时调用它,因为每次出现时我都想隐藏状态栏,因此为了 DRY 原则,它应该包含在动画本身中。
【问题讨论】:
-
能否请您展示您实际尝试的代码以及崩溃时的堆栈跟踪?
-
我会上传一个样本,秒。
-
@AaronBrager 添加了示例。
标签: ios swift uiviewcontroller ios8 uipresentationcontroller