- 打開圖片
引入第三方庫XLPhotoBrowser
XLPhotoBrowser *browser = [XLPhotoBrowser showPhotoBrowserWithImages:imageUrlArray currentImageIndex:selectedNum];
browser.browserStyle = XLPhotoBrowserStyleIndexLabel; // 微博樣式
- 打開文件
@property (nonatomic,strong) UIDocumentInteractionController *documentInteractionController;
//創(chuàng)建存儲(chǔ)路徑
+ (void)creatDir:(NSString*)dirPath{
if (![[NSFileManager defaultManager] fileExistsAtPath:dirPath]){//判斷dirPath路徑文件夾是否已存在沟于,此處dirPath為需要新建的文件夾的絕對(duì)路徑
[[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:nil];//創(chuàng)建文件夾
}
}
//創(chuàng)建fileUrl
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *caches = [paths firstObject];
[CH_Utils creatDir:[caches stringByAppendingString:@"/Documents"]];
NSString *savedPath = [caches stringByAppendingString:[NSString stringWithFormat:@"/Documents/%@",fileName]];
打開URL
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileUrl];
[_documentInteractionController setDelegate:self];
[_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
還有webView和QLPreviewController打開文檔笙僚,隨后更新