Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在某些情况下,取消UIDocumentInteractionController将删除显示视图控制器';IOS 7 iPad中的s视图_Iphone_Objective C_Ipad_Ios7_Ipad 3 - Fatal编程技术网

Iphone 在某些情况下,取消UIDocumentInteractionController将删除显示视图控制器';IOS 7 iPad中的s视图

Iphone 在某些情况下,取消UIDocumentInteractionController将删除显示视图控制器';IOS 7 iPad中的s视图,iphone,objective-c,ipad,ios7,ipad-3,Iphone,Objective C,Ipad,Ios7,Ipad 3,解除UIDocumentInteractionController时,显示视图控制器的视图将被删除,包括UINavigationController中的元素 UIDocumentInteractionController将解散,并且呈现视图控制器的视图将被删除,在呈现视图控制器以前存在的位置留下一个纯白色/灰色的框。在此之后,应用程序不再响应任何触摸事件 这发生在iPad模拟器(iOS 7.0)和运行iOS 7的iPad3(Wifi)上,用于快速查看Pdf阅读器 不管应用程序是根据iOS 6.1

解除UIDocumentInteractionController时,显示视图控制器的视图将被删除,包括UINavigationController中的元素

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

这发生在iPad模拟器(iOS 7.0)和运行iOS 7的iPad3(Wifi)上,用于快速查看Pdf阅读器

不管应用程序是根据iOS 6.1还是iOS 7 SDK编译的


请让我知道您的建议。

在iOS 7中,当我在iPad上以模式表单形式呈现视图控制器时,我遇到了同样的问题(在iOS 6中工作正常)

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

我解决了这个问题,在文档交互控制器预览开始时保留了对演示视图控制器的根视图(层次结构中阴影视图的前一个)的引用,并在文档交互控制器预览结束时将该视图恢复到层次结构

下面是示例代码:

    - (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是从popover显示的,则需要稍加修改

存在对视图层次结构的轻微依赖,可以通过在父视图上迭代直到找到具有UIWindow superview的父视图来消除这种依赖。此外,我发现,当从popover中显示文档交互控制器时,需要存储为parentView和containerView的视图略有不同(特别是我们希望找到一个containerView,以便其superview是UIPopoverView)。下面的代码片段是Michael的答案的重新设计版本,用于合并这些更改(注意UIPopoverView是一个私有类,因此我们使用该类的字符串表示,而不是直接引用每个类):


我遇到了完全相同的问题,应用程序在一个灰色表单模式视图上暂停,在UIDocumentInteractionController出现并被撤销后,该视图丢失了所有内容。这里的两个解决方案都很好,但我对它们进行了简化,以满足我的特殊情况,即表单表单模式中的UINavigationController可以在UIDocumentInteractionController中显示PDF,我希望是全屏模式,而不是在导航控制器中推送,因为表单表区域太小,PDF很难阅读

我实现了两个UIDocumentInteractionControllerDelegate方法。假设如下:

  • self.navController
    是对表单模式中显示的UINavigationController的引用
  • UIViewController子类
    @property(非原子,强)UIView*docInteractionControllerWorkaroundSuperview中声明了一个成员变量
  • 系统版本(大于或等于)是
    定义的
    ([[[UIDevice currentDevice]systemVersion]比较:v选项:NSNumericSearch]!=传感器解除搜索)
首先:

-(UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller
{    
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") && self.navigationController.modalPresentationStyle == UIModalPresentationFormSheet)
    {
        self.docInteractionControllerWorkaroundSuperview = [self.navigationController.view superview];
    }
    return self.navigationController.visibleViewController;
}
然后:

i、 e.展示UIDocumentInteractionController时,请查看导航控制器视图的superview。它是一个UIDropShadowView,我假设它是表单模型的部分透明的灰色/黑色背景,它使模型后面的视图变暗


解除PDF后,在
documentInteractionControllerDidEndPreview
中,导航控制器视图的超级视图现在是UITransistionView。但之后不久(当转换完成时),它就被设置为nil。不知何故,它与UIDropShadowView分离(或没有重新连接)。通过在呈现UIDocumentInteractionController时保留一个查看此内容的引用,我们可以手动重新连接它,一切正常。然后确保将引用置零,以确保我们不会意外地保留它


此方法不会影响iOS 6或任何以前的iOS版本上的行为。

您的委派方法类似于-(UIViewController*)DocumentInteractionControllerServiceControllerForpReview:(UIDocumentInteractionController*)控制器{return self.navigationController;}此处存在相同的问题。。。在委托我的方法return self.viewMichael中-您使用什么工具来检查视图层次结构?@ChrisMarkle在调试器中,编写
po[yourView recursiveDescription]
以获取层次结构。documentInteractionControllerDidEndPreview在我的情况下未被调用。有什么帮助吗?@MayankJain您在创建UIDocumentInteractionController时设置了它的委托吗?在调用该方法时,您为委托创建的对象是否仍然存在(例如,没有因为离开屏幕等而被删除)?
-(UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller
{    
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") && self.navigationController.modalPresentationStyle == UIModalPresentationFormSheet)
    {
        self.docInteractionControllerWorkaroundSuperview = [self.navigationController.view superview];
    }
    return self.navigationController.visibleViewController;
}
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    if (self.docInteractionControllerWorkaroundSuperview != nil)
    {
        NSLog(@"Workaround iOS 7 document interaction bug... resetting nav controller view into modal");

        //reset the nav controller view from whence it came.
        self.navigationController.view.frame = CGRectMake(0.0, 0.0, self.navigationController.view.frame.size.width, self.navigationController.view.frame.size.height);
        [self.docInteractionControllerWorkaroundSuperview addSubview:self.navigationController.view];

        self.docInteractionControllerWorkaroundSuperview = nil;
    }
}