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
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];
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
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.