UIDocumentInteractionController无法通过AirDrop发送文件

时间:2016-04-27 22:59:43

标签: ios uidocumentinteraction airdrop

我正在使用UIDocumentInteractionController来共享KML(Geo XML)文件。当我使用UIDocumentInteractionController时,我可以在其他应用程序中打开KML文件。我可以通过电子邮件发送。但是,当我尝试通过AirDrop分享它到我的Mac时,我收到此错误消息。我知道AirDrop可以在我的iPhne和我的Mac之间工作,因为我可以在其他应用程序中使用它。我实际上可以将KML从我的应用程序共享到另一个应用程序,然后通过AirDrop从其他应用程序共享KML文件。

Sender kSFOperationEventErrorOccured {  
    Error = "Error Domain=SFOperation Code=-1 \"Transfer failed.  Try again.\" UserInfo={NSLocalizedDescription=Transfer failed.  Try again.}";  
    Files =     (  
                {  
            FileBomPath = "./topoMapsExport.kml";  
            FileIsDirectory = 0;  
            FileName = "topoMapsExport.kml";  
            FileType = "com.trailbehind.kml";  
        }  
    );  
    ReceiverComputerName = "Stephen\U2019s MacBook Pro";  
    ReceiverID = 994fcdc90a7d;  
    ReceiverModelName = "MacBook Pro";  
    SessionID = 3C1A7DF67296;  
    TotalBytes = 11857;  
    UsePKZip = 0;  
    VerifiableIdentity = 0;  
}  

有谁知道为什么通过AirDrop分享会失败?

以下是我设置文档交互控制器的方法。

//Path is the path to my kml file.  The path does exist and it has the correct data in it.  
    NSURL* url = [NSURL fileURLWithPath:path];  

    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:url];  
    self.documentController.UTI = @"com.google.earth.kml";  
    self.documentController.name = @"topoMapsExport.kml";  
    [self.documentController presentOptionsMenuFromRect:self.exportButton.frame inView:self.view animated:YES];  

1 个答案:

答案 0 :(得分:0)

也许定义self.documentControler.delegate

并添加

#pragma mark - UIDocumentInteractionControllerDelegate

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
    return self;
}