iOS 8 - Screen blank after dismissing view controller with custom presentation(iOS 8 - 使用自定义演示关闭视图控制器后屏幕空白)
问题描述
当使用 UIModalPresentationCustom 关闭各种视图控制器时,关闭视图控制器后屏幕变黑,就好像所有视图控制器都已从视图层次结构中删除一样.
When dismissing various view controllers using UIModalPresentationCustom, the screen turns black after the view controller is dismissed, as if all the view controllers had been removed from the view hierarchy.
transitioning delegate 设置正确,animationControllerForPresentedController 被请求并正确传递,动画结束后transition 完成.
The transitioning delegate is set properly, the animationControllerForPresentedController is asked for and passed correctly, and the transition is completed once the animation is over.
这个确切的代码在使用 iOS 7 SDK 编译时可以完美运行,但在使用 iOS 8b5 编译时会损坏
This exact code works perfectly when compiled with the iOS 7 SDK, but is broken when compiled with iOS 8b5
推荐答案
这是因为你很可能同时添加了演示文稿
This is because you are most likely adding both the presenting
[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]
和呈现的
[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]
在动画控制器的 (void)animateTransition:(id )transitionContext 方法中查看控制器到您的 containerView.由于您使用的是自定义模态展示,展示视图控制器仍显示在展示的视图控制器下方.现在因为它仍然可见,您不需要将它添加到容器视图中.而是只将呈现的视图控制器添加到 containerView.在你的 animateTransition: 方法中应该看起来像这样
view controllers to your containerView in the (void)animateTransition:(id )transitionContext method of your animation controller. Since you are using a custom modal presentation, the presenting view controller is still shown beneath the presented view controller. Now since it's still visible you don't need to add it to the container view. Instead only add the presented view controller to the containerView. Should look something like this inside of your animateTransition: method
UIView *containerView = [transitionContext containerView];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// Boolean value to determine presentation or dismissal animation
if (self.presenting){
[transitionContext.containerView addSubview:toViewController.view];
// Your presenting animation code
} else {
// Your dismissal animation code
}
这篇关于iOS 8 - 使用自定义演示关闭视图控制器后屏幕空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 8 - 使用自定义演示关闭视图控制器后屏幕空白
基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
