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


- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01