[英]How to open files in a UIWebView?
我只是為iOS創建文件瀏覽器,我只需要知道如何在UIWebview中打開任何類型的文件。 我認為webview可以打開任何類型的文件,這是因為我選擇使用UIWebView直接在應用程序中查看文件。 現在我的問題。
如何以編程方式切換到同一UIStoryBoard中的UIViewController並顯示文件? 文件URL存儲在名為path
的字符串中。
這就是我的票價,我只需要添加文件查看器。
有人能幫我嗎?
-(void) displayFile:(NSString*)fileName
{
NSError *error = nil;
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
TO get the filename
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:fileName];
if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath]) //Optionally check if folder already hasn't existed.
{
// do something
}
}
希望這對您有幫助...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.