iOS笔记UI--文件显示

通过webView显示本地或者网络文件。 文件的类型可以是:doc、xls、ppt、jpg、png、pdf等格式。

//
//  ViewController.m
//  文件显示
//
//  Created by hhg on 15/10/23.
//  Copyright (c) 2015年 hhg. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

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

    NSString *path = [[NSBundle mainBundle] pathForResource:@"jxysc" ofType:@"doc"];

    //加载本地文件
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];

    //加载网络文件
//    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end

猜你喜欢

转载自blog.csdn.net/csdn_hhg/article/details/80458465