在某些情况下解除UIDocumentInteractionController将删除IOS 7 iPad中呈现视图控制器的视图 [英] Dismissing a UIDocumentInteractionController in some cases will remove the presenting view controller's views in IOS 7 iPad

查看:444
本文介绍了在某些情况下解除UIDocumentInteractionController将删除IOS 7 iPad中呈现视图控制器的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当解除UIDocumentInteractionController时,将删除呈现视图控制器的视图,包括UINavigationController中的元素。

When the UIDocumentInteractionController is dismissed, the presenting view controller's views are removed, including elements from the UINavigationController.

UIDocumentInteractionController解除并删除呈现视图控制器的视图,留下一个纯白/灰框,其中呈现视图控制器以前存在。在此之后,应用程序不再响应任何触摸事件。

The UIDocumentInteractionController dismisses and the presenting view controller's views are removed, leaving a plain white/gray box where the presenting view controller formerly existed. The app no longer responds to any touch events after this point.

在运行iOS 7 for Quick Look Pdf的iPad模拟器(iOS 7.0)和iPad 3(Wifi)上发生这种情况读者。

This Occurs on iPad Simulator (iOS 7.0) and iPad 3 (Wifi) running iOS 7 for Quick Look Pdf Reader.

无论应用程序是针对iOS 6.1还是iOS 7 SDK编译的,都是无关紧要

Does not matter whether the application was compiled against the iOS 6.1 or iOS 7 SDK

请让我知道你的建议。

推荐答案

从视图控制器呈现UIDocumentInteractionController时,我遇到了同样的问题。 iOS 7中的iPad(在iOS 6中运行良好)。

I have this same problem when presenting a UIDocumentInteractionController from a view controller presented as a modal form sheet on iPad in iOS 7 (worked fine in iOS 6).

看起来在从文档交互控制器转换回呈现视图控制器的过程中,呈现视图控制器的视图被包装在临时UITransitionView中,然后转换在转换完成后,视图将从视图层次结构中移除,同时显示视图控制器的视图,只留下UIDropShadowView,它是可见的模态表单的背景视图(灰色框)。

It looks like that during the transition from the document interaction controller back to the presenting view controller, the presenting view controller's view is wrapped in a temporary UITransitionView, and then that transition view is being removed from the view hierarchy after the transition is complete, along with the presenting view controller's view, leaving just UIDropShadowView that is the backing view of the modal form sheet visible (the gray box).

我通过在文档交互控制器预览开始时保持对我的呈现视图控制器的根视图(层次结构中的阴影视图之前的那个)的引用来解决该问题,并将该视图恢复为文档交互控制器预览结束时的层次结构。

I worked around the problem by keeping a reference to my presenting view controller's root view (the one just before the drop shadow view in the hierarchy) when the document interaction controller preview will begin, and restoring that view to the hierarchy when the document interaction controller preview has ended.

以下是示例代码:

    - (void)documentInteractionControllerWillBeginPreview:(__unused UIDocumentInteractionController *)controller {

    if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
        // work around iOS 7 bug on ipad

        self.parentView = [[[self.view superview] superview] superview];
        self.containerView = [self.parentView superview];

        if (![[self.containerView superview] isKindOfClass: [UIWindow class]]) {
            // our assumption about the view hierarchy is broken, abort
            self.containerView = nil;
            self.parentView = nil;
        }
    }
}

    - (void)documentInteractionControllerDidEndPreview:(__unused UIDocumentInteractionController *)controller {

    if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
        if (!self.view.window && self.containerView) {
            assert(self.parentView);
            CGRect frame = self.parentView.frame;
            frame.origin = CGPointZero;
            self.parentView.frame = frame;
            [self.containerView addSubview: self.parentView];
            self.containerView = nil;
            self.parentView = nil;
        }
    }
}

这篇关于在某些情况下解除UIDocumentInteractionController将删除IOS 7 iPad中呈现视图控制器的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆