链接到WebView - iPhone中的资源 [英] Link to resources inside WebView - iPhone
问题描述
我在我的iPhone应用程序中有一个webview,并且我的Resources文件夹中也有一些html文件。当我的应用程序加载时,我从我的资源加载到我的webview中。但是,我需要在我的webview中创建指向其他一些资源(例如图像或其他html文件)的链接。只是做一个相对的链接不起作用:
I have a webview in my iPhone application, and I also have some html files inside my Resources folder. When my app loads, I load in a page from my resources into my webview. But , I need to make links inside my webview that point to some other resources (For example, images, or other html files). Just doing a relative link doesn't work:
<a href="OtherPage.html">Doesn't work</a>
推荐答案
当您加载这些资源时,您需要设置基本网址。你可以使用这个方法来做到这一点:
When you load those resources, you need to set the base URL. You can do this using the method:
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
...其中baseURL将成为资源文件夹的文件网址。
...where baseURL would be the file URL of your resources folder.
这篇关于链接到WebView - iPhone中的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!