iphone - 在某些情况下关闭 UIDocumentInteractionController 将删除 IOS 7 iPad 中呈现 View Controller 的 View

标签 iphone objective-c ipad ios7 ipad-3

当 UIDocumentInteractionController 被解除时,呈现 View Controller 的 View 将被删除,包括来自 UINavigationController 的元素。

UIDocumentInteractionController 关闭并且呈现 View Controller 的 View 被删除,在呈现 View Controller 以前存在的地方留下一个纯白色/灰色框。在此之后,应用不再响应任何触摸事件。

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

无论应用程序是针对 iOS 6.1 还是 iOS 7 SDK 编译的

请告诉我您的建议。

最佳答案

在 iOS 7 的 iPad 上以模态表单形式呈现的 View Controller 呈现 UIDocumentInteractionController 时,我遇到了同样的问题(在 iOS 6 中运行良好)。

看起来在从文档交互 Controller 转换回呈现 View Controller 的过程中,呈现 View Controller 的 View 被包装在一个临时的 UITransitionView 中,然后在转换完成后从 View 层次结构中删除该转换 View 完成,连同呈现 View Controller 的 View ,只留下 UIDropShadowView,它是可见的模态表单的后备 View (灰色框)。

我通过在文档交互 Controller 预览开始时保留对呈现 View Controller 的 Root View (层次结构中投影 View 之前的那个)的引用来解决这个问题,并在文档交互 Controller 预览已结束。

示例代码如下:

    - (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;
        }
    }
}

关于iphone - 在某些情况下关闭 UIDocumentInteractionController 将删除 IOS 7 iPad 中呈现 View Controller 的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19462710/

相关文章:

iphone - iPhone 与 iPad/浏览器上的 HTML5 内联视频

ios - 如何让用户从应用程序内的字体、大小和颜色列表中进行选择?

iphone - 从 iphone 导入/导出数据

iphone - 添加导航 Controller 的 UIButton 顶栏,推送到另一个 viewController

iphone - 在屏幕顶部显示绿色条以返回应用程序

ios - 点击后更改 UIView/UIControl 的屏幕位置

ios - 桥接 header 将框架导入 View Controller

ios - iOS 7 上的 UINavigationBar Flash

objective-c - 带有 UIButtons 的 UIScrollview - 如何重新创建跳板?

iphone - 链接到应用程序商店进行更新 - iPhone 不能在 iPad 上使用吗?