DocViewer (Document/File Viewer)
Document Viewer (Word & & Excel & & PDF & & Rft || Network & & Local || self & & other App)
File Sharing (Network & & Local)
needed to pay attention
1. If we make HTTP requests directly under iOS9, we will receive the following error prompt
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
We'll be told that we can't make requests directly using HTTP and that we need to add a new configuration to Info.plist to control ATS
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
That is:
2. If you want to share your app's document viewing capabilities, add them in info.plist
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array> <string>MySmallIcon.png</string> <string>MyLargeIcon.png</string> </array> <key>CFBundleTypeName</key> <string>My File Format</string> <key>LSHandlerRank</key> <string>Owner</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>
Property description:
CFBundleTypeName: The type name of the document
LSHandlerRank: This refers to whether or not you have subdocuments
3. In info.plist, add Chinese for the corresponding Localization native development region key value
4. After a third party invokes our APP, the following methods are invoked
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options { if (options) { NSString *str = [NSString stringWithFormat:@"\n Of the application that sent the request Bundle ID: %@\n\n File NSURL: %@", options[UIApplicationOpenURLOptionsSourceApplicationKey], url]; NSLog(@"%@", str); if (self.window && url) { // Open with this app according to Other Apps and enter the list page through url [self pushDocListViewControllerWithUrl:url]; } } return YES; } #pragma mark ApplicationDelegate Method /** Open with this app according to Other Apps and enter the list page through url */ - (void)pushDocListViewControllerWithUrl:(NSURL *)url { // Open with'This Application'based on'Other Applications' and get the local address from the url you want to open NSString *appFilePath = [[JhtDocFileOperations sharedInstance] findLocalPathFromAppLicationOpenUrl:url]; // Jump Page DocListViewController *doc = [[DocListViewController alloc] init]; doc.appFilePath = appFilePath; [_nav pushViewController:doc animated:YES]; }
5. Library Files
System Library: WebKit.framework
Triple library: AFNetworking3.x
how to use
1. Configuration of related parameters
a. JhtDocFileOperations: File Operations Class: Contains methods such as file saving &&cleaning
b. JhtShowDumpingViewParamModel: Slide-down prompt box configuration parameter model
Sets the size, color, position, background image, whether the text in the prompt box contains small warning icons, etc.
c. JhtFileModel: Model to download the document
Set parameters such as file ID, file name, absolute path (local file), file size, etc.
2. Use integration: see demo for more details, and note the code associated with AppDelegate and DocListViewController
3. DocListViewController: Document List
The data source for the tableView is an array with a model that determines whether to download based on the attribute fileAbsolutePath (local absolute path)
4. JhtLoadDocViewController: Document Details VC
a. If you don't need to download it, display it directly through webView
b. To download, use the class method in the JhtDownloadRequest function to download, pause, etc. (Note: JhtFileModel property: fileSize, should be written in this form "KB,MB,GB,Bytes". In order to calculate the remaining memory of the mobile phone, whether the relationship can be downloaded successfully
c. Resource Sharing
JhtDocViewer File With Other Applications Open
Other Applications file opens with JhtDocViewer