gpt4 book ai didi

ios - 无法连接到 URL ms-word URL 方案

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:58:54 24 4
gpt4 key购买 nike

我将用户发送到 Microsoft Word 应用程序以编辑文档。为此,我使用了一个 URL 方案,该方案已在我的 info.plist 中作为“ms-word”列入白名单。我读到的所有关于此的问题和答案都是我尝试过多次的过时/涉及解决方案。

在您说“只需使用 UIDocumentInteractionController”之前,该文档 Controller 不允许编辑同一文件,并且它无法在查看文档后将用户发送回原始应用程序。

这是我在 Objective - C 中尝试过的内容

NSURL *ourURL = [NSURL URLWithString:[@"ms-word:ofe|u|https://www.acm.org/sigs/publications/pubform.doc" stringByAddingPercentEscapesUsingEncoding:(NSUTF8StringEncoding)]];
if([[UIApplication sharedApplication] canOpenURL:ourURL] ) {
[[UIApplication sharedApplication] openURL:ourURL];
}

我也尝试过这种方法的变体,例如删除编码并手动将管道编码为 %7C,因为这就是编码后的最终结果。我看到的教程中使用了此变体 here .

这是另一个 tutorial我看着那对我不起作用。

我还尝试通过按文件类型 .doc/.docx 搜索在 google 上找到的其他面向公众的 word 文档,但均无效。

这是我在 Swift 中尝试过的

let ourURL = NSURL(string: ("ms-word:ofe|u|http://www.fcu.edu.tw/wSite/public/Attachment/f1355389313906.doc").stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!)!
print(ourURL)
let ourApplication:UIApplication = UIApplication.sharedApplication()
if(ourApplication.canOpenURL(ourURL)) {
ourApplication.openURL(ourURL)
}

我再次尝试了多种变体、不同的编码、NSUTF8、stringByAddingPercentEscapesUsingAllowedCharacters(NSCharacters.URLQueryAllowedCharacterSet()),以及不同的 word 文档 url...

我也试过下载文档的 NSData 并将其写入本地到我手机中的文件目录,然后打开该文件,但是 URL 方案没有支持本地目录(UIDocumentInteractionController 确实支持这一点,但同样,您不能编辑该副本,也不能将用户返回到他们的应用程序)。

little documentation关于 ms word 的 url 方案,我已经对该主题进行了大量研究,似乎仍有很多人仍然遇到同样的问题并转到了 Microsoft forums和其他没有解决方案的帮助论坛,因为这些论坛中挤满了在该特定领域没有经验的人。

每次尝试都会导致:

1) Word 成功启动,但随后我收到此错误:“无法连接到 URL,请使用有效的 URL

2) Word 成功启动,但随后我收到相同的错误,然后在消除错误后我看到类似“word 无法打开位于 url 的文件”之类的内容

最佳答案

我了解到我一直收到此错误,因为这根本不可能

要使 ms-word url 方案起作用,文档必须存在于 SharePoint 或 OneDrive 中,说明 here .

You can enable users who are running Office on an iOS device to open and edit files stored in SharePoint or OneDrive from any application, and then quickly return them to the original application when they’re done editing the file.

关于ios - 无法连接到 URL ms-word URL 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38528983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com