美文网首页
UIWebView加载文件

UIWebView加载文件

作者: ssssky | 来源:发表于2016-08-16 17:07 被阅读0次
- (void)viewDidLoad {
    [super viewDidLoad];

    //添加webView
    UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    webView.scalesPageToFit = YES;
    [self.view addSubview:webView];

    //获取文件路径
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    //拼接文件名
    NSString *filePath = [docPath stringByAppendingPathComponent:@"b.doc"];

    NSURL *url = [NSURL fileURLWithPath:filePath];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
}

相关文章

网友评论

      本文标题:UIWebView加载文件

      本文链接:https://www.haomeiwen.com/subject/dbvpsttx.html