
https://iodefog.github.io/
// 下面代码为打开弹框,效果图如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
- (IBAction)buttonClicked:(id)sender { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = [paths firstObject]; NSString *cachePath = nil; NSFileManager *manager = [NSFileManager defaultManager] ; if (![manager fileExistsAtPath:documentPath]) { NSLog(@"没有文件"); }else { NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:documentPath ] objectEnumerator]; NSString *fileName = nil; while ((fileName = [childFilesEnumerator nextObject]) != nil ){ NSString* fileAbsolutePath = [documentPath stringByAppendingPathComponent:fileName]; BOOL isDirectory = NO; NSLog(@"filePath %@", fileName); cachePath = [NSString stringWithFormat:@"%@/%@",documentPath, fileName]; if ([manager fileExistsAtPath:fileAbsolutePath isDirectory:&isDirectory]){ NSDictionary *dic = [manager attributesOfItemAtPath:fileAbsolutePath error:nil] ; NSLog(@"%@", dic); } break; } } UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:cachePath]]; documentController.delegate = self; [documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; }
-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{ }
-(void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application{ }
-(void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller{ }
|

如果需要自己的应用也支持别的应用调用:则需要配置info.plist 如下:
)
效果图:

近期评论