|
|
@@ -7,12 +7,14 @@
|
|
|
//
|
|
|
|
|
|
#import "LocalDocumentsViewController.h"
|
|
|
-#import <QuickLook/QuickLook.h>
|
|
|
+#import "MyQLPreviewController.h"
|
|
|
|
|
|
-@interface LocalDocumentsViewController () <QLPreviewControllerDelegate,QLPreviewControllerDataSource>
|
|
|
+@interface LocalDocumentsViewController () <QLPreviewControllerDelegate,QLPreviewControllerDataSource,UIDocumentInteractionControllerDelegate>
|
|
|
|
|
|
-@property (nonatomic,strong) QLPreviewController *quickLook;
|
|
|
+@property (nonatomic,strong) MyQLPreviewController *quickLook;
|
|
|
@property (nonatomic,copy) NSString *selectedDocumentPath;
|
|
|
+@property (nonatomic,strong) UIDocumentInteractionController *documentController;
|
|
|
+
|
|
|
|
|
|
@end
|
|
|
|
|
|
@@ -126,11 +128,11 @@
|
|
|
NSString *filename;
|
|
|
while (filename = [direnum nextObject])
|
|
|
{
|
|
|
- if ([[filename pathExtension] isEqualToString:@"pdf"])
|
|
|
- {
|
|
|
+// if ([[filename pathExtension] isEqualToString:@"pdf"])
|
|
|
+// {
|
|
|
NSString *filePath = [path stringByAppendingPathComponent:filename];
|
|
|
[manager removeItemAtPath:filePath error:nil];
|
|
|
- }
|
|
|
+// }
|
|
|
}
|
|
|
[self.toolsinfo removeAllObjects];
|
|
|
[self.tableview reloadData];
|
|
|
@@ -247,6 +249,9 @@
|
|
|
[tableView reloadData];
|
|
|
}
|
|
|
|
|
|
+ NSString *emailPath = [self emailPathForFile:filePath];
|
|
|
+ [[NSFileManager defaultManager] removeItemAtPath:emailPath error:nil];
|
|
|
+
|
|
|
}];
|
|
|
|
|
|
return @[delete];
|
|
|
@@ -331,14 +336,58 @@
|
|
|
return self.view;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Share
|
|
|
+
|
|
|
+- (void)shareClick:(id)sender {
|
|
|
+ [self shareDocument];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)shareDocument {
|
|
|
+
|
|
|
+ NSString *filePath = self.selectedDocumentPath;
|
|
|
+ NSString *emailPath = [self emailPathForFile:filePath];
|
|
|
+
|
|
|
+ NSURL *fileURL = [NSURL fileURLWithPath:filePath];
|
|
|
+
|
|
|
+ if (self.documentController == nil) {
|
|
|
+ UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
|
|
|
+ documentController.delegate = self;
|
|
|
+ documentController.UTI = @"com.adobe.pdf";
|
|
|
+ self.documentController = documentController;
|
|
|
+ } else {
|
|
|
+ self.documentController.URL = fileURL;
|
|
|
+ }
|
|
|
+ self.documentController.annotation = @{@"_toRecipients" : @[@"676034647@qq.com"]};
|
|
|
+ self.documentController.name = @"Test";
|
|
|
+
|
|
|
+ // [self.documentController presentOpenInMenuFromRect:self.navigationController.topViewController.view.bounds
|
|
|
+ // inView:self.navigationController.topViewController.view
|
|
|
+ // animated:YES];
|
|
|
+
|
|
|
+ [self.documentController presentOptionsMenuFromRect:self.navigationController.topViewController.view.bounds
|
|
|
+ inView:self.navigationController.topViewController.view
|
|
|
+ animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (NSString *)emailPathForFile:(NSString *)file {
|
|
|
+ if (file == nil) {
|
|
|
+ return nil;
|
|
|
+ }
|
|
|
+ NSString *fileName = [file lastPathComponent];
|
|
|
+ NSString *emailPath = [[file stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@".%@",fileName]];
|
|
|
+ return emailPath;
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Quick Look
|
|
|
|
|
|
-- (QLPreviewController *)quickLook {
|
|
|
+- (MyQLPreviewController *)quickLook {
|
|
|
if (!_quickLook)
|
|
|
{
|
|
|
- _quickLook = [[QLPreviewController alloc] init];
|
|
|
+ _quickLook = [[MyQLPreviewController alloc] init];
|
|
|
_quickLook.delegate = self;
|
|
|
_quickLook.dataSource = self;
|
|
|
+ UIBarButtonItem *shareBtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"ic_share_new"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(shareClick:)];
|
|
|
+ _quickLook.navigationItem.rightBarButtonItem = shareBtn;
|
|
|
}
|
|
|
else
|
|
|
{
|