Created
November 10, 2011 16:37
-
-
Save kwylez/1355329 to your computer and use it in GitHub Desktop.
Main Thread Loading of Local UIWebView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// loadRequest | |
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" | |
ofType:@"html"] isDirectory:NO]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:htmlPath]; | |
[webView loadRequest:request]; | |
[self.view addSubview:webView]; | |
[webView release]; | |
// loadHTMLString | |
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" | |
ofType:@"html"] isDirectory:NO]; | |
NSString *htmlString = [NSString stringWithContentsOfURL:htmlPath encoding:NSUTF8StringEncoding error:nil]; | |
[webView loadHTMLString:htmlString baseURL:nil]; | |
[self.view addSubview:webView]; | |
[webView release]; | |
// loadHTMLData | |
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"about" | |
ofType:@"html"]]; | |
[webView loadData:data MIMEType:@"text/html" textEncodingName:@"html" baseURL:nil]; | |
[self.view addSubview:webView]; | |
[webView release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment