標籤:根據 window poi 檔案夾 content .net cal osi hive
根據需求需要在項目中要開啟word、pdf、excel等檔案,在info.plist檔案中添加
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string></string> <key>LSItemContentTypes</key> <array> <string>com.microsoft.powerpoint.ppt</string> <string>public.item</string> <string>com.microsoft.word.doc</string> <string>com.adobe.pdf</string> <string>com.microsoft.excel.xls</string> <string>public.image</string> <string>public.content</string> <string>public.composite-content</string> <string>public.archive</string> <string>public.audio</string> <string>public.movie</string> <string>public.text</string> <string>public.data</string> </array> </dict> </array>
第三方應用開啟檔案會調用下面的代理方法
/** 開啟檔案調用的代理方發 @param application 自己的app @param url 第三方應用調用時檔案的沙箱地址 @param sourceApplication 調用我們APP的第三方應用是誰 @param annotation @return 傳回值是YES */- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation{ if (self.window) { if (url) { NSString *fileNameStr = [url lastPathComponent]; NSString *Doc = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/localFile"] stringByAppendingPathComponent:fileNameStr]; NSData *data = [NSData dataWithContentsOfURL:url]; [data writeToFile:Doc atomically:YES]; NSLog(@"檔案已存到本地檔案夾內"); } } return YES;}
ios調用第三方程式開啟檔案,以及第三方調用自己的APP開啟檔案
iOS APP中第三方APP調用自己的APP,開啟檔案