|  | @@ -39,6 +39,7 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #import "KSNewAlertView.h"
 | 
	
		
			
				|  |  |  #import "KSLogManager.h"
 | 
	
		
			
				|  |  | +#import "KSSourceDownloadAlert.h"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |      CHOOSETYPE_XML,
 | 
	
	
		
			
				|  | @@ -74,13 +75,20 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) KSUMShareManager *shareManager;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -@property (nonatomic, assign) BOOL isDownloadFile;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) KSNewAlertView *wifiAlert;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 是否需要重新加载
 | 
	
		
			
				|  |  |  @property (nonatomic, assign) BOOL needReload;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +@property (nonatomic, assign) BOOL isDownloadFile;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@property (nonatomic, strong) NSDictionary *downloadParm;
 | 
	
		
			
				|  |  | +// 下载文件地址
 | 
	
		
			
				|  |  | +@property (nonatomic, strong) NSURL *downloadFileUrl;
 | 
	
		
			
				|  |  | +//文件预览(写全局变量,否则操作不成功)
 | 
	
		
			
				|  |  | +@property (nonatomic, strong) UIDocumentInteractionController *documentVC;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @end
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @implementation KSBaseWKWebViewController
 | 
	
	
		
			
				|  | @@ -377,6 +385,10 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |              }];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"downloadFile"]) {
 | 
	
		
			
				|  |  | +        NSString *url = [[parm ks_dictionaryValueForKey:@"content"] ks_stringValueForKey:@"downloadUrl"];
 | 
	
		
			
				|  |  | +        [self downloadFileWithUrl:url parm:parm];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      // 回调是否刘海屏
 | 
	
		
			
				|  |  |      else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"isSpecialShapedScreen"]) {
 | 
	
		
			
				|  |  |          BOOL isShapedScreen = iPhoneXSafeTopMargin > 0 ? YES : NO;
 | 
	
	
		
			
				|  | @@ -757,6 +769,83 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +- (void)downloadFileWithUrl:(NSString *)fileUrl parm:(NSDictionary *)parm {
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER showCustomLoading:@"文件下载中"];
 | 
	
		
			
				|  |  | +    [KSNetworkingManager downloadFileRequestWithFileUrl:fileUrl progress:^(int64_t bytesRead, int64_t totalBytes) {
 | 
	
		
			
				|  |  | +        // 显示进度
 | 
	
		
			
				|  |  | +        NSInteger progress = (NSInteger)(bytesRead*1.0 / totalBytes) * 100;
 | 
	
		
			
				|  |  | +        NSString *tipsString = [NSString stringWithFormat:@"文件下载中\n%zd%%",progress];
 | 
	
		
			
				|  |  | +        dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showCustomLoading:tipsString];
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    } success:^(NSURL * _Nonnull fileUrl) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeCustomLoading];
 | 
	
		
			
				|  |  | +        // 修改文件名
 | 
	
		
			
				|  |  | +        NSURL *saveUrl = fileUrl;
 | 
	
		
			
				|  |  | +        NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
 | 
	
		
			
				|  |  | +        NSString *fileName = [content ks_stringValueForKey:@"fileName"];
 | 
	
		
			
				|  |  | +        if (![NSString isEmptyString:fileName]) { // 重命名
 | 
	
		
			
				|  |  | +            saveUrl = [self renameFile:fileUrl withNewName:fileName];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        [self saveFileWithPath:saveUrl sendParm:parm];
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nonnull error) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeCustomLoading];
 | 
	
		
			
				|  |  | +        [self downloadCallback:NO withParm:parm];
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)downloadCallback:(BOOL)isSuccess withParm:(NSDictionary *)parm {
 | 
	
		
			
				|  |  | +    NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
 | 
	
		
			
				|  |  | +    NSMutableDictionary *content = [NSMutableDictionary dictionaryWithDictionary:[parm ks_dictionaryValueForKey:@"content"]];
 | 
	
		
			
				|  |  | +    [content setValue:@(isSuccess) forKey:@"isSuccess"];
 | 
	
		
			
				|  |  | +    [sendParm setValue:content forKey:@"content"];
 | 
	
		
			
				|  |  | +    [self postMessage:sendParm];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (NSURL *)renameFile:(NSURL *)fileUrl withNewName:(NSString *)fileName {
 | 
	
		
			
				|  |  | +    // 获取文件的路径
 | 
	
		
			
				|  |  | +    NSURL *directoryURL = [fileUrl URLByDeletingLastPathComponent];
 | 
	
		
			
				|  |  | +    // 旧文件名
 | 
	
		
			
				|  |  | +    NSString *oldFileName = [fileUrl lastPathComponent];
 | 
	
		
			
				|  |  | +    NSString *fileExtension = [oldFileName pathExtension];
 | 
	
		
			
				|  |  | +    // 当前时间戳
 | 
	
		
			
				|  |  | +    NSTimeInterval interval = [[NSDate date] timeIntervalSince1970] *1000;
 | 
	
		
			
				|  |  | +    // 构建新的文件名
 | 
	
		
			
				|  |  | +    NSString *newFileName = [NSString stringWithFormat:@"%.0f_%@.%@", interval, fileName, fileExtension];
 | 
	
		
			
				|  |  | +    // 构建新文件的完整 URL
 | 
	
		
			
				|  |  | +    NSURL *newURL = [directoryURL URLByAppendingPathComponent:newFileName];
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    // 使用 NSFileManager 移动文件以重命名
 | 
	
		
			
				|  |  | +    NSFileManager *fileManager = [NSFileManager defaultManager];
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    // 如果存在newURL 移除
 | 
	
		
			
				|  |  | +    if ([fileManager fileExistsAtPath:[newURL path]]) {
 | 
	
		
			
				|  |  | +        [fileManager removeItemAtURL:newURL error:nil];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    NSError *error = nil;
 | 
	
		
			
				|  |  | +    BOOL success = [fileManager moveItemAtURL:fileUrl toURL:newURL error:&error];
 | 
	
		
			
				|  |  | +    if (success) {
 | 
	
		
			
				|  |  | +        return newURL;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        return fileUrl;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)saveFileWithPath:(NSURL *)fileUrl sendParm:(NSDictionary *)parm {
 | 
	
		
			
				|  |  | +    self.downloadParm = parm;
 | 
	
		
			
				|  |  | +    self.isDownloadFile = YES;
 | 
	
		
			
				|  |  | +    self.downloadFileUrl = fileUrl;
 | 
	
		
			
				|  |  | +    // 保存到文件目录下
 | 
	
		
			
				|  |  | +    KSDocumentViewController *documentPickerVC = [[KSDocumentViewController alloc] initWithURL:fileUrl inMode:UIDocumentPickerModeExportToService];
 | 
	
		
			
				|  |  | +    // 设置代理
 | 
	
		
			
				|  |  | +    documentPickerVC.delegate = self;
 | 
	
		
			
				|  |  | +    // 设置模态弹出方式
 | 
	
		
			
				|  |  | +    documentPickerVC.modalPresentationStyle = UIModalPresentationFormSheet;
 | 
	
		
			
				|  |  | +    [self.navigationController presentViewController:documentPickerVC animated:YES completion:nil];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  - (void)downloadWithParm:(NSDictionary *)parm {
 | 
	
		
			
				|  |  |      MJWeakSelf;
 | 
	
		
			
				|  |  |      [COURSEWARE_MANAGER downloadCourseWithParm:parm callback:^(NSDictionary * _Nonnull sendParm) {
 | 
	
	
		
			
				|  | @@ -849,7 +938,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)saveFileToPhone:(NSURL *)fileUrl {
 | 
	
		
			
				|  |  |      self.isDownloadFile = YES;
 | 
	
		
			
				|  |  | -    UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURL:fileUrl inMode:UIDocumentPickerModeExportToService];
 | 
	
		
			
				|  |  | +    self.downloadFileUrl = fileUrl;
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    KSDocumentViewController *documentPicker = [[KSDocumentViewController alloc] initWithURL:fileUrl inMode:UIDocumentPickerModeExportToService];
 | 
	
		
			
				|  |  |      documentPicker.delegate = self;
 | 
	
		
			
				|  |  |      documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
 | 
	
		
			
				|  |  |      [self presentViewController:documentPicker animated:YES completion:nil];
 | 
	
	
		
			
				|  | @@ -1585,12 +1676,146 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |  - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
 | 
	
		
			
				|  |  |      if (self.isDownloadFile) {
 | 
	
		
			
				|  |  |          self.isDownloadFile = NO;
 | 
	
		
			
				|  |  | +        if (self.downloadParm) {
 | 
	
		
			
				|  |  | +            [self downloadCallback:NO withParm:self.downloadParm];
 | 
	
		
			
				|  |  | +            self.downloadParm = nil;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      else {
 | 
	
		
			
				|  |  |          [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls {
 | 
	
		
			
				|  |  | +    if (self.isDownloadFile) {
 | 
	
		
			
				|  |  | +        self.isDownloadFile = NO;
 | 
	
		
			
				|  |  | +        [self downloadCallback:YES withParm:self.downloadParm];
 | 
	
		
			
				|  |  | +        self.downloadParm = nil;
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        NSURL *descUrl = [urls firstObject];
 | 
	
		
			
				|  |  | +        NSString *desc = [descUrl absoluteString];
 | 
	
		
			
				|  |  | +        KSSourceDownloadAlert *alertView = [KSSourceDownloadAlert shareInstance];
 | 
	
		
			
				|  |  | +        [alertView configWithDesc:desc];
 | 
	
		
			
				|  |  | +        [alertView actionCallbackCancel:^{
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +        } copyCallback:^{
 | 
	
		
			
				|  |  | +            [self copyAction:desc];
 | 
	
		
			
				|  |  | +        } sure:^{
 | 
	
		
			
				|  |  | +            [self openFileSource:descUrl];
 | 
	
		
			
				|  |  | +        }];
 | 
	
		
			
				|  |  | +        [alertView showAlert];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        NSURL *url =  [urls lastObject];
 | 
	
		
			
				|  |  | +        NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"];
 | 
	
		
			
				|  |  | +        NSString *fileName = [array lastObject];
 | 
	
		
			
				|  |  | +        fileName = [fileName stringByRemovingPercentEncoding];
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        if (self.fileChooseType == CHOOSETYPE_XML) {
 | 
	
		
			
				|  |  | +            if (![fileName hasSuffix:@".xml"]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传XML格式文件"];
 | 
	
		
			
				|  |  | +                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else if (self.fileChooseType == CHOOSETYPE_MIDI) {
 | 
	
		
			
				|  |  | +            if (![fileName hasSuffix:@".mid"] || [fileName hasSuffix:@".midi"]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传mid格式文件"];
 | 
	
		
			
				|  |  | +                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else if (self.fileChooseType == CHOOSETYPE_MP3) {
 | 
	
		
			
				|  |  | +            if (![fileName hasSuffix:@".mp3"]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传mp3格式文件"];
 | 
	
		
			
				|  |  | +                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            if (![fileName hasSuffix:@".mp3"] && ![fileName hasSuffix:@".aac"]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"暂不支持此格式!"];
 | 
	
		
			
				|  |  | +                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        __block NSString * fileUrl = @"";
 | 
	
		
			
				|  |  | +        if ([KSICloudManager iCloudEnable]) {
 | 
	
		
			
				|  |  | +            [KSICloudManager downloadWithDocumentURL:url callBack:^(id obj) {
 | 
	
		
			
				|  |  | +                NSData *data = obj;
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                //写入沙盒Documents
 | 
	
		
			
				|  |  | +                 NSString *pathStr = [NSHomeDirectory() stringByAppendingString:[NSString stringWithFormat:@"/Documents/%@",fileName]];
 | 
	
		
			
				|  |  | +                [data writeToFile:pathStr atomically:YES];
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                if (![[NSFileManager defaultManager] fileExistsAtPath:pathStr]) {
 | 
	
		
			
				|  |  | +                    BOOL isSuccess = [data writeToFile:pathStr atomically:YES];
 | 
	
		
			
				|  |  | +                    if (isSuccess) {
 | 
	
		
			
				|  |  | +                        fileUrl = pathStr;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    else {
 | 
	
		
			
				|  |  | +                        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"写入文件错误!"];
 | 
	
		
			
				|  |  | +                        [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else {
 | 
	
		
			
				|  |  | +                    fileUrl = pathStr;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                [self uploadFile:fileName fileUrl:pathStr];
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +            }];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"iCloud不可用!"];
 | 
	
		
			
				|  |  | +            [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)openFileSource:(NSURL *)path {
 | 
	
		
			
				|  |  | +    if (self.downloadFileUrl) {
 | 
	
		
			
				|  |  | +        [self displayFileWithUrl:path];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        // 开始访问权限
 | 
	
		
			
				|  |  | +        BOOL fileUrlAuthozied = [path startAccessingSecurityScopedResource];
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        if (fileUrlAuthozied) {
 | 
	
		
			
				|  |  | +            // 通过 NSFileCoordinator 来协调读取
 | 
	
		
			
				|  |  | +            NSFileCoordinator *fileCoordinator = [[NSFileCoordinator alloc] init];
 | 
	
		
			
				|  |  | +            NSError *error = nil;
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            [fileCoordinator coordinateReadingItemAtURL:path options:0 error:&error byAccessor:^(NSURL *newURL) {
 | 
	
		
			
				|  |  | +                // 打开文档
 | 
	
		
			
				|  |  | +                [self displayFileWithUrl:newURL];
 | 
	
		
			
				|  |  | +            }];
 | 
	
		
			
				|  |  | +            // 释放权限
 | 
	
		
			
				|  |  | +            [path stopAccessingSecurityScopedResource];
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"无法访问文件"];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)displayFileWithUrl:(NSURL *)url {
 | 
	
		
			
				|  |  | +    // 打开文档
 | 
	
		
			
				|  |  | +    self.documentVC = [UIDocumentInteractionController interactionControllerWithURL:url];
 | 
	
		
			
				|  |  | +    // 2. 设置代理(如果需要处理特定交互事件)
 | 
	
		
			
				|  |  | +    self.documentVC.delegate = self;
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    // 3. 显示“打开方式”菜单或文件预览
 | 
	
		
			
				|  |  | +    // 从指定的视图呈现操作菜单
 | 
	
		
			
				|  |  | +    [self.documentVC presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)copyAction:(NSString *)desc {
 | 
	
		
			
				|  |  | +    // 复制
 | 
	
		
			
				|  |  | +    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
 | 
	
		
			
				|  |  | +    pasteboard.string = [NSString returnNoNullStringWithString:desc];
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER MBShowAUTOHidingInWindow:@"复制成功"];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  - (void)fileChooseErrorCallback {
 | 
	
		
			
				|  |  |      if (self.chooseFileParm) { // 回调
 | 
	
		
			
				|  |  |          [self.chooseFileParm setValue:@"" forKey:@"fileUrl"];
 | 
	
	
		
			
				|  | @@ -1599,8 +1824,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  - (void)uploadFile:(NSString *)fileName fileUrl:(NSString *)fileUrl {
 | 
	
		
			
				|  |  |      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
 | 
	
		
			
				|  |  |          [LOADING_MANAGER showHUD];
 | 
	
	
		
			
				|  | @@ -1682,80 +1905,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
 | 
	
		
			
				|  |  |  -(CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController*)controller {
 | 
	
		
			
				|  |  |      return self.view.frame;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -#pragma mark - UIDocumentPickerDelegate
 | 
	
		
			
				|  |  | -- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls {
 | 
	
		
			
				|  |  | -    if (self.isDownloadFile) {
 | 
	
		
			
				|  |  | -        self.isDownloadFile = NO;
 | 
	
		
			
				|  |  | -        //保存成功
 | 
	
		
			
				|  |  | -       [LOADING_MANAGER MBShowAUTOHidingInWindow:@"保存成功"];
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    else {
 | 
	
		
			
				|  |  | -        NSURL *url =  [urls lastObject];
 | 
	
		
			
				|  |  | -        NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"];
 | 
	
		
			
				|  |  | -        NSString *fileName = [array lastObject];
 | 
	
		
			
				|  |  | -        fileName = [fileName stringByRemovingPercentEncoding];
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        if (self.fileChooseType == CHOOSETYPE_XML) {
 | 
	
		
			
				|  |  | -            if (![fileName hasSuffix:@".xml"]) {
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传XML格式文件"];
 | 
	
		
			
				|  |  | -                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if (self.fileChooseType == CHOOSETYPE_MIDI) {
 | 
	
		
			
				|  |  | -            if (![fileName hasSuffix:@".mid"] || [fileName hasSuffix:@".midi"]) {
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传mid格式文件"];
 | 
	
		
			
				|  |  | -                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if (self.fileChooseType == CHOOSETYPE_MP3) {
 | 
	
		
			
				|  |  | -            if (![fileName hasSuffix:@".mp3"]) {
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请上传mp3格式文件"];
 | 
	
		
			
				|  |  | -                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            if (![fileName hasSuffix:@".mp3"] && ![fileName hasSuffix:@".aac"]) {
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"暂不支持此格式!"];
 | 
	
		
			
				|  |  | -                [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        __block NSString * fileUrl = @"";
 | 
	
		
			
				|  |  | -        if ([KSICloudManager iCloudEnable]) {
 | 
	
		
			
				|  |  | -            [KSICloudManager downloadWithDocumentURL:url callBack:^(id obj) {
 | 
	
		
			
				|  |  | -                NSData *data = obj;
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                //写入沙盒Documents
 | 
	
		
			
				|  |  | -                 NSString *pathStr = [NSHomeDirectory() stringByAppendingString:[NSString stringWithFormat:@"/Documents/%@",fileName]];
 | 
	
		
			
				|  |  | -                [data writeToFile:pathStr atomically:YES];
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                if (![[NSFileManager defaultManager] fileExistsAtPath:pathStr]) {
 | 
	
		
			
				|  |  | -                    BOOL isSuccess = [data writeToFile:pathStr atomically:YES];
 | 
	
		
			
				|  |  | -                    if (isSuccess) {
 | 
	
		
			
				|  |  | -                        fileUrl = pathStr;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else {
 | 
	
		
			
				|  |  | -                        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"写入文件错误!"];
 | 
	
		
			
				|  |  | -                        [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else {
 | 
	
		
			
				|  |  | -                    fileUrl = pathStr;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                [self uploadFile:fileName fileUrl:pathStr];
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -            }];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"iCloud不可用!"];
 | 
	
		
			
				|  |  | -            [self fileChooseErrorCallback];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #pragma mark ---- 镜像和投屏检测
 | 
	
		
			
				|  |  |  - (void)captureViewTips:(NSNotification *)notification {
 |