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 - 使用自定义演示关闭视图控制器后屏幕空白


基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01