标签: uidocumentinteraction

是否可以为多个项目提供UIDocumentInteractionController?

iOS 7中的照片应用程序允许您选择多张照片,点击"共享"并显示文档交互控制器以及多个项目的相应选项.

Camera应用程序更进一步,甚至可以在您选择和取消选择照片时实时更新文档交互控制器的选项.

但是,UIDocumentInteractionController类似乎只允许单个URL参数.

是否可以使用公共API执行照片和相机应用程序的操作?

ios uidocumentinteraction ios7

4
推荐指数
1
解决办法
2159
查看次数

UIDocumentInteractionController中没有选项

是否可以检查设备上有多少应用程序可以处理特定文件类型?基本上,我的应用程序中有一个按钮,允许用户打开另一个应用程序,但如果没有可能的应用程序打开文档,我不想显示它.

iphone uidocumentinteraction

3
推荐指数
1
解决办法
1571
查看次数

使用QLPreviewController或UIDocumentInteractionController打开没有扩展名的文件

有没有办法用QLPreviewController或UIDocumentInteractionController打开文件,知道它的UTI,但在NSURL中没有文件扩展名?谢谢你的帮助!

ios qlpreviewcontroller uidocumentinteraction

3
推荐指数
1
解决办法
1473
查看次数

UIDocumentInteractionController无法打开应用程序(didEndSendingToApplication:从不调用)

我有一个UIDocumentInteractionController实例(DOES在我班上一个有力的参考,我知道关于它的内存问题),我想将照片文件发送到Instagram的.

我使用ig扩展名保存了文件(尝试igo过)并且我正在呈现控制器.Instagram显示在列表中.我点击Instagram,没有任何反应.

NSURL *imageFile = [NSURL fileURLWithPath:path];
interactionController = [UIDocumentInteractionController interactionControllerWithURL:imageFile];
interactionController.UTI = @"com.instagram.photo";
interactionController.annotation = [NSDictionary dictionaryWithObject:@"my caption" forKey:@"InstagramCaption"];
interactionController.delegate = self;
[interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)

为了进一步调查,我将我的调用类设置为委托并实现了willBeginSendingToApplication:didEndSendingToApplication:方法.有趣的是,我意识到willBeginSendingToApplication:确实会被调用,但didEndSendingToApplication:事实并非如此.我已经尝试更改我的文件扩展名,将UTI更改为com.instagram.exclusivegram,检查文件URL是否正确等等,但它们似乎都不起作用.没有错误,控制台中没有任何东西.交互控制器关闭,我的应用程序保持工作,因为它以前工作,没有任何反应.我已经读过iOS 6上可能存在一些问题,但我的应用程序是iOS 6应用程序,所以我无法在iOS <6上测试它.我发现的唯一接近我的问题的是UIDocumentInteractionController,没有文件扩展但UTI,但它过多地进入低级别位,我也没有非ARC代码.

可能是问题的原因是什么?

ios uidocumentinteraction ios6

3
推荐指数
2
解决办法
4475
查看次数

在另一个应用程序中打开文件时,在UIDocumentInteractionController中更改文件名

我以一种掩盖文件原始名称的方式将文件存储在我的应用程序沙箱中.

例如,我有一个名为abc.png的文件,它以obfuscated.png的形式存储在沙箱中.

当我使用UIDocumentInteractionController在另一个应用程序中打开此文件时,我想让另一个文件打开文件名为abc.png的文件

目前,另一个应用程序将文件打开为obfuscated.png.

我已经尝试更改in 的name属性以及,但是在这两种情况下接收应用程序都没有获得正确的文件名 - 它继续显示模糊的文件名.UIDocumentInteractionControllerdocumentInteractionControllerWillPresentOptionsMenuwillBeginSendingToApplication

除了使用未经模糊处理的名称创建文件的副本之外,有没有办法让接收应用程序使用所需的文件名?

cocoa-touch uikit ios uidocumentinteraction

3
推荐指数
1
解决办法
981
查看次数

UIDocumentInteractionController 文件附件错误

所以我正在从 Xcode 导出一个 .txt 文件,但是每当我尝试导出它时,比如通过电子邮件,它会创建一封没有附件和空消息的电子邮件。当我尝试将其导出到 iCloud Drive 时,白屏出现一秒钟,然后离开。当我检查 iCloud Drive 时,该文件不存在。这里有什么问题?

let message = testLabel.text

func getDocumentsDirectory() -> NSString {
    let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
    let documentsDirectory = paths[0]
    return documentsDirectory as NSString
}

let filePath = getDocumentsDirectory().appendingPathComponent("matrixFile.txt")

do{
    try message?.write(toFile: filePath, atomically: true, encoding: String.Encoding.utf8)
}catch let error as NSError{
    testLabel.text = String(describing: error)
}

let documentInteractionController = UIDocumentInteractionController()
documentInteractionController.url = NSURL.fileURL(withPath: filePath)
documentInteractionController.uti = "public.data, public.content"
documentInteractionController.name = "matrixFile"
documentInteractionController.presentOptionsMenu(from: view.frame, in: view, animated: true)
Run Code Online (Sandbox Code Playgroud)

uidocumentinteraction swift swift3

3
推荐指数
1
解决办法
1592
查看次数

UIDocumentInteractionController没有出现在iPad上但在iPhone上工作

我正在尝试UIDocumentInteractionController在我的应用上显示一个.一切都在iPhone上完美运行,但iPad上什么也没发生.这是我的代码:

    interactionController = [UIDocumentInteractionController interactionControllerWithURL:imageFile];
    interactionController.UTI = @"com.instagram.photo";
    interactionController.annotation = [NSDictionary dictionaryWithObject:[self commentForInstagram] forKey:@"InstagramCaption"];
    [interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)

interactionController是对实例的强引用,并且imageFile存在.在iPhone上,它会显示"打开方式..."对话框并且Instagram存在.在iPad上,上述代码运行时绝对没有任何反应.是的,我确实安装了Instagram并在我的iPad上工作.

可能是代码执行时没有发生任何事情的原因?self.view并且self.view.frame是有效的对象(在调试时测试).

谢谢,可以.

ipad ios uidocumentinteraction ios6

2
推荐指数
1
解决办法
5946
查看次数

如何使用Swift 3在应用程序中共享音频文件?

在Swift中共享音频文件

如何将应用文档目录中存在的音频文件共享给其他应用?

要详细说明这个问题,我的意思是当用户点击应用程序中的分享按钮时,他们应该能够将他们录制的音频轨道通过电子邮件发送给另一个人,或者能够将其发送到一系列其他应用程序中可以像声音云一样处理音频.

研究这个主题,我发现:

  • UIActivityViewController
  • UIDocumentInteractionController

由于我的应用程序对他们应该能够共享的人的语音进行录音,并且尽管搜索了堆栈溢出,但我还是找不到一个代码示例,说明如何在Swift应用程序中实现此选项.我可以请求有关如何完成此操作的建议和示例代码.非常感谢,

audio share uidocumentinteraction uiactivityviewcontroller ios-sharesheet

2
推荐指数
1
解决办法
2378
查看次数

urlSession 从远程 url 下载失败 - 出现 CFNetworkDownload_gn6wzc.tmp

我试图使用从远程 url 下载文件urlSession。但是,当下载完成后,出现了一个意外的文件,名为“CFNetworkDownload_gn6wzc.tmp然后我无法使用uidocumentinteractioncontroller.该文件是什么?”打开该文件。如何解决这个问题。感谢您的回复。

这是消息

Your location is file:///Users/pisal/Library/Developer/CoreSimulator/Devices/26089E37-D4EA-49E5-8D45-BB7D9C52087D/data/Containers/Data/Application/767E966E-5954-41BA-B003-90E2D27C5558/Library/Caches/com.apple.nsurlsessiond/Downloads/com.SamboVisal.downloadTask/CFNetworkDownload_gn6wzc.tmp

这是我的示例代码:我通过此方法发送链接

@IBAction func startDownload(_ sender: Any) {
    let url = URL(string: "http://www.tutorialspoint.com/swift/swift_tutorial.pdf")!
    let task = DownloadManager.shared.activate().downloadTask(with: url)
    task.resume()

}
Run Code Online (Sandbox Code Playgroud)

然后下载完成后:

func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
        debugPrint("Download finished: \(location)")
        debugPrint("download task : \(downloadTask)")
        ViewController().documentInteraction(location: location)

    }
Run Code Online (Sandbox Code Playgroud)

当我试图打开时uidocumentinteractioncontroller

let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString
    let destinationPath = documentDirectoryPath.appendingPathComponent("swift.pdf")
    let destinationUrl = URL(fileURLWithPath: destinationPath)

    do{
        try FileManager.default.copyItem(at: locat, to: destinationUrl)
    } …
Run Code Online (Sandbox Code Playgroud)

uidocumentinteraction nsurlsession nsurlsessiondownloadtask swift iosdeployment

2
推荐指数
1
解决办法
3399
查看次数

UIDocumentInteractionController在iBooks中打开pdf崩溃

我有一个测试PDF文件,我想通过我的应用程序在iBooks中打开.我将它保存在我的临时目录中,并使用此代码将其加载到iBooks:

NSURL *targetURL = [NSURL fileURLWithPath:tempFullPath];
NSLog(@"Path is %@", tempFullPath);
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:targetURL];
controller.delegate = self;
controller.UTI = @"com.adobe.pdf";

[controller presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)

弹出的菜单很好但是当我点击iBooks按钮时,应用程序崩溃并挂起我的Xcode.

我在NSLog输出中获得的文件路径如下:

Path is /private/var/mobile/Applications/65EC4182-A79B-431C-9E74-BD72D91A31AB/tmp/TestFile.pdf
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?提前致谢!

cocoa-touch objective-c ibooks ios uidocumentinteraction

1
推荐指数
1
解决办法
3422
查看次数

哪些文件类型可以UIDocumentInteractionController预览?

我将一个UIDocumentInteractionController放入我的应用程序,它可以从服务器下载任意文件类型.

这有两个目的:

  1. 允许用户在另一个可能能够查看该文件的应用程序中"打开"该文件.
  2. 预览内置UIDocumentInteractionController能够预览的文件.

我想要的是只尝试显示系统能够预览的文件类型的预览.例如,如果它是一个zip文件,系统无法预览,所以我想直接进入'Open In'.

我无法在任何地方找到支持预览的类型列表.

这是我的代码:

self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
[self.docController setDelegate:self];

// I'd like to skip this line if the system can't preview the file.     

BOOL isOpen = [self.docController presentPreviewAnimated:YES];
if (!isOpen) {
    BOOL canOpen = [self.docController presentOpenInMenuFromRect:CGRectMake(300, 300, 100, 100)
                                                          inView:self.view
                                                        animated:NO];
    if (!canOpen) {
          // tell user to install an app that's able to open this file.
          return;
     }
}
Run Code Online (Sandbox Code Playgroud)

objective-c uikit ios uidocumentinteraction

1
推荐指数
1
解决办法
3185
查看次数

UIDocumentInteractionController 不适用于 Instagram

我需要将图像文件共享到Instagram,根据Instagram文档: https: //www.instagram.com/developer/mobile-sharing/iphone-hooks/,我可以使用文档交互来实现这一点,但它只是没有不工作。这是我的代码:

        let img = UIImage(named: "test.jpg")
        let kInstagramURL = URL(string: "instagram://")
        let kUTI = "com.instagram.exclusivegram" // testing "com.instagram.photo" too
        let instagramCaption = "TESTING"
        let kfileNameExtension = "instagram.igo" // testing "jpg"/"ig" too

        if UIApplication.shared.canOpenURL(kInstagramURL!) {
            let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
            if urls.count == 0 {
                print("Not found")
                return
            }
            let url = urls[0].appendingPathComponent(kfileNameExtension)
            print("URL", url)
            // OUPUT: file:///var/mobile/Containers/Data/Application/F14B18CB-5CD4-47AD-8257-E2288C23181E/Documents/instagram.igo
            do {
                try UIImageJPEGRepresentation(img!, 1.0)?.write(to: url, options: .atomic)
                print("WRITEN", url) // Written successfully, no error
            } catch { …
Run Code Online (Sandbox Code Playgroud)

ios uidocumentinteraction instagram swift

1
推荐指数
1
解决办法
1248
查看次数