记录人生道路景色的,点点滴滴。
// 下面代码为打开弹框,效果图如下:
123456789101112131415161718192021222324252627282930313233343536373839404142434445
- (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 如下:)
效果图: