iOS查看office文檔(系統(tǒng)自帶)

注:在模擬器中可能下載下文件但沒內容顯示,需要在真機上運行測試使用

1、導入頭文件

#import<QuickLook/QuickLook.h>

遵守協(xié)議 :QLPreviewControllerDataSource,QLPreviewControllerDelegate

2、 ??

@property(nonatomic,strong)NSString*deFilePath; ?//這個是存到本地的文件地址

例如:

file:///Users/lilianming/Library/Developer/CoreSimulator/Devices/5322EE30-3908-4791-BB13-37FF7272ACF4/data/Containers/Data/Application/851245D6-C482-4397-8585-60392C3F4E64/Documents/20160315180123_8ekihq.xlsx

- (void)quickLookFiles ?//初始化 代理 設置當前頁?

{?

???QLPreviewController*preView = [[QLPreviewControlleralloc]init];

??? preView.dataSource=self;

??? preView.delegate=self;

??? preView.currentPreviewItemIndex=0;

??? [self.navigationControllerpushViewController:preViewanimated:YES];

}

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController*)controller

{

???return1;

}

- (id)previewController:(QLPreviewController*)previewController previewItemAtIndex:(NSInteger)idx{

?return[NSURLURLWithString:_deFilePath];//返回的要是一個URL形式 ?&& 直接返回網(wǎng)址能打開嗎?

}

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容