“如何打开”;index.html“第1页”;UIWebView中的本地链接?
我已经使用以下代码在我的web视图中打开本地HTML文件“如何打开”;index.html“第1页”;UIWebView中的本地链接?,html,ios,objective-c,url,webview,Html,Ios,Objective C,Url,Webview,我已经使用以下代码在我的web视图中打开本地HTML文件 NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil]; [webView loadHTMLString:ht
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:htmlString baseURL:nil];
但是现在我想打开“index.html#page1”类型的html链接。其中,“index.html”是主html文件,“#page1”是同一html文件上的div id。像
<div data-role="page" id="page1"></div>
如何在我的WebView上使用这种类型的HTML链接?一个可能的(未测试),htmlFile
是文件的路径,因此您可以使用它,而不是加载htmlString
,而是从路径加载URL。