Home Tutorial Iphone Examples Embedding HTML in iPhone App

 
 

Share on Google+Share on Google+
Embedding HTML in iPhone App
Posted on: August 9, 2010 at 12:00 AM
Advertisement
This example illustrate you how to embed the HTML in iPhone application. To embed the HTML file we required a UIWebView that will load the page in our application.

Embedding HTML in iPhone App

This example illustrate you how to embed the HTML in iPhone application. To embed the HTML file we required a UIWebView that will load the page in our application.

Once you create your application with UIWebView, create your ".html" file and add it under Resources folder. And just copy the given code into your view controller implementation file.

Syntax to embed HTML into UIWebView iphone app

- (void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"corejava" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];

NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];

webView.opaque = NO;
webView.backgroundColor = [UIColor purpleColor];
[self.webView loadHTMLString:htmlString baseURL:nil];
[htmlString release];

}

The application will look like ...

If you do not want the color background in the UIWebView then do the needfull...
1. Set the UIWebView background property as clearColor
2. In HTML file <body style="background-color: transparent"> and
3. Set the opaque = NO

Download Code

Advertisement

Related Tags for Embedding HTML in iPhone App:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com