直接上代码
//获取webView
UIWebView * webView=(UIWebView *)self.view;
//设置代理
webView.delegate=self;
//创建一个url对象,和pathForResource差不多前面是文件名,后面是后缀
NSURL * url=[[NSBundle mainBundle]URLForResource:self.help.html withExtension:nil];
//通过一个统一的资源定位符,包装成一个请求
NSURLRequest * request=[NSURLRequest requestWithURL:url];
//加载请求
[webView loadRequest: request];
//网页加载完成执行js代码,跳转到相应的行,让相应的行跳到最上面
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString * code=[NSString stringWithFormat:@"document.location.href = '#%@';",self.help.ids];
[webView stringByEvaluatingJavaScriptFromString:code];
}