How do I load an HTML file into my app (xcode)? I’m using the following code:
- (void)viewDidLoad
{
[super viewDidLoad];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
}
When I start the app, I only see a white page. What’s wrong?
.h file:
#import <UIKit/UIKit.h>
@interface poules : UIViewController {
IBOutlet UIWebView *webView;
}
@property (nonatomic,retain) UIWebView *webView;
@end
Here is a working example from one of my projects. My
index.htmlfile is in a folder calledDocumentation/htmlin the resources directory. Its important to note that these are “folder references“, not groups (hence the blue icon):then to load it in a
webView: