大佬教程收集整理的这篇文章主要介绍了ios – UIDocumentInteractionController“invalid scheme(null)”,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
'UIDocumenTinteractionController: invalid scheR_332_11845@e (null). Only the file scheR_332_11845@e is supported.'
我使用下面的代码:
- (void) webserviceController:(WebserviceController *)webserviceController returnedArray:(NSMutableArray *)array { if ([webserviceController.webrequest isEqualToString: @"generateExcelFileForemployee"]) { // start previewing the document at the current section index NSString *link = [[NSString StringWithString:array[0]] StringByreplacingoccurrencesOfString:@"AdminFunctions.PHP" withString:@"AdminFunctions.xls"]; link = [[[link StringByreplacingoccurrencesOfString:@"\\" withString:@""]StringByreplacingoccurrencesOfString:@"/public/sites/" withString:@"http://"]StringByreplacingoccurrencesOfString:@"\"\\\"" withString:@""]; NSLog(@"%@",link); NSData *urlData = [NSData dataWithContentsOfURL:[NSURL URLWithString:link]]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentsDirectory = [paths objectATindex:0]; NSString *filePath = [NSString StringWithFormat:@"%@/%@",documentsDirectory,@"AdminFunctions.xls"]; BOOL isWritesuccess = [urlData writeToFile:filePath atomically:YES]; NSLog(@"%@",filePath); if(isWritesuccess) //success { file = [NSURL fileURLWithPath:filePath]; self.fileView = [self setupControllerWithURL:file usingDelegate:self]; [self.fileView presentPreviewAnimated:YES]; } else { NSLog(@"file not written"); } } } - (UIDocumenTinteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumenTinteractionControllerDelegate>) interactionDelegate { UIDocumenTinteractionController *interactionController = [UIDocumenTinteractionController interactionControllerWithURL: fileURL]; interactionController.delegate = interactionDelegate; return interactionController; } - (UIViewController *) documenTinteractionControllerViewControllerForPreview: (UIDocumenTinteractionController *) controller { return self; }
这两种方法都在我想呈现预览的viewcontroller中实现.我知道很难,我得到的数据在urlData对象,因为当我放入断点,控制台说,它包含6144字节,这正是要下载的文件的大小.
我一直在寻找这个安静的一段时间,但我似乎无法弄清楚如何解决这个问题.我已经尝试将link对象作为documenTinteractionController的源,但是错误更改为:
'UIDocumenTinteractionController: invalid scheR_332_11845@e (http). Only the file scheR_332_11845@e is supported.'
任何关于如何克服这个问题的意见将被高度赞赏
file = [NSURL fileURLWithPath:filePath];
代替
file = [NSURL URLWithString:filePath];
以上是大佬教程为你收集整理的ios – UIDocumentInteractionController“invalid scheme(null)”全部内容,希望文章能够帮你解决ios – UIDocumentInteractionController“invalid scheme(null)”所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。