- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.title = @"图片新闻";

//新建网页视图

webView = [[UIWebView alloc]initWithFrame:self.view.bounds];

//网页视图自适应屏幕尺寸

webView.scalesPageToFit = YES;

//设置代理

webView.delegate = self;

[self.view addSubview:webView];

//加载百度

// //创建request对象

// NSMutableURLRequest *mResquest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];

// //网页控件加载一个

// [webView loadRequest:mResquest];

//初始化风火轮

UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:ac];

self.navigationItem.rightBarButtonItem = rightItem;

[self _loadData];

}

- (void)_loadData{

NSString *filePath = [[NSBundle mainBundle]pathForResource:@"news" ofType:@"html"];

NSError *error = nil;

NSString *str = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];

NSDictionary *jsonData = [ReturnJson showJson:news_detail];

NSString *title = [jsonData objectForKey:@"title"];

NSString *source = [jsonData objectForKey:@"source"];

NSString *time = [jsonData objectForKey:@"time"];

NSString *author = [jsonData objectForKey:@"author"];

NSString *content = [jsonData objectForKey:@"content"];

NSString *htmlStr = [NSString stringWithFormat:str,title,source,time,content,author];

[webView loadHTMLString:htmlStr baseURL:nil];

}

#pragma mark-UIWebViewDelegate

//开始加载

- (void)webViewDidStartLoad:(UIWebView *)webView{

UIActivityIndicatorView *ac = (UIActivityIndicatorView *)self.navigationItem.rightBarButtonItem;

[ac startAnimating];

}

//结束加载

- (void)webViewDidFinishLoad:(UIWebView *)webView{

UIActivityIndicatorView *ac = (UIActivityIndicatorView *)self.navigationItem.rightBarButtonItem;

[ac stopAnimating];

}

//加载出错

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}