Monday 17 November 2008

Loading HTML from the Main App Bundle

To load a static HTML from the main app bundle (useful to initialize web views in some way) use the following code:


//fakes a URL
NSString * urlStr = @"http://myServer/mypage.html";
// loads the actual HTML
NSString * html = [NSString stringWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"phone" ofType:@"html"]];
// loads and displays the page
[thisWebView loadHTMLString:html baseURL:[NSURL URLWithString: urlStr]];

No comments: