iDocumentInteractionController在使用iOS7的iphone上的怪异行为

iDocumentInteractionController在使用iOS7的iphone上的怪异行为,ios7,malloc,xcode5,uidocumentinteraction,Ios7,Malloc,Xcode5,Uidocumentinteraction,我有一个问题已经两天了,我需要你的帮助。在我开始之前,我应该说这个问题出现在带iOS7的iPhone5上(我也在带iOS6的iPhone4和带iOS7的iPad2上进行了测试)。当我尝试升级AppStore上的应用程序(最初是iOS4)并尝试使其与IOS7兼容(从iOS6开始支持)时,这个问题就开始了 情况非常简单。我看到的是一个UIDocumentInteractionControllerDelegate。我从web服务下载一个文件,并将其保存在NSTemporaryDirectory中,允许

我有一个问题已经两天了,我需要你的帮助。在我开始之前,我应该说这个问题出现在带iOS7的iPhone5上(我也在带iOS6的iPhone4和带iOS7的iPad2上进行了测试)。当我尝试升级AppStore上的应用程序(最初是iOS4)并尝试使其与IOS7兼容(从iOS6开始支持)时,这个问题就开始了

情况非常简单。我看到的是一个UIDocumentInteractionControllerDelegate。我从web服务下载一个文件,并将其保存在NSTemporaryDirectory中,允许用户使用PresentOptions MenuFromRect预览或在另一个应用程序中打开。简化代码如下:

我已经声明了一个@property(非原子,强)UIDocumentInteractionController*docController

@autoreleasepool {
    NSString *fileName = "uniquefilename"
        NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
        fileURL = [NSURL fileURLWithPath:filePath];
        NSFileManager *fileManager = [NSFileManager defaultManager];
        if(![fileManager fileExistsAtPath:filePath]){
            NSData *fileData = [NSData dataWithContentsOfURL:[NSURL URLWithString:"theurlofthefile"]];
            NSError *writeError = nil;
            [fileData writeToURL: fileURL options:0 error:&writeError];
            if(writeError) {
                //show error  
            }
        }

docController = [UIDocumentInteractionController interactionControllerWithURL:url];
    docController.delegate = self;
    if (isIpad) {
        [docController presentOptionsMenuFromRect:CGRectMake(location.x + 400,location.y, 100, 100) inView:tableView animated:YES];
    }
    else{
        [docController presentOptionsMenuFromRect:CGRectZero inView:self.tabBarController.view animated:YES];
    }    
}
问题是我收到了各种各样的错误,我一直重复相同的过程,我得到了不同的错误,有时它连续工作了很多次,有时它从一开始就失败了。当我再次收到错误时,我将添加以下错误:

  • *由于未捕获的异常“NSGenericeException”而终止应用程序,原因:*收集在 正在列举。”

  • malloc:*对象0x177a56a4的错误:的校验和不正确 释放的对象-对象可能在被释放后被修改

  • malloc:*对象0x1c2c8b50的错误:双自由*设置a malloc中的断点\u错误\u中断以进行调试

  • 当选项菜单成功显示时,我在控制台中看到“AirDrop:collectionView:layout:InsetForSectionIndex:,方向:1,sectionInset:{0,10,0,10}”

    我尝试启用NSZombies并为malloc错误设置断点,但没有任何帮助

    请帮助我或指引我到正确的方向


    谢谢。

    回答有点晚,但希望它能帮助其他人

    我在保存文件和演示UIDocumentInteractionController时遇到了完全相同的问题,它是绝对随机的,有时会连续出现10次,有时会在第一次尝试时崩溃


    这似乎是由于文件未完成磁盘写入,对我来说,解决这个问题的方法是在显示UIDocumentInteractionController之前增加延迟,以确保文件已完成写入磁盘

    您是否尝试过相同的代码,但没有自动释放池封装它?是的,但没有任何区别。我还尝试在try-catch块中添加几段代码,但我同样没有捕获任何异常,我也经历了同样的情况。。是的,有时它是随机工作的。