views:

62

answers:

1

For some reason, the first method doesn't display anything, while the second does:

//Common
NSString *path=[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
//Method1
[webView loadRequest:[NSURLRequest requestWithURL: [NSURL fileURLWithPath: path isDirectory: NO]]];
//Method 2
NSString *HTML=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
[webView loadHTMLString:HTML baseURL:[NSURL URLWithString:[[NSBundle mainBundle] bundlePath]]];
//Common        
UIViewController* controller=[webView controllerWithTitle:@"Help"];
[delegateRef.navController pushViewController:controller animated:YES];

On the other hand, I also tried loading it using a URL as well. Similarly, the first method didn't display anything while the second did.

//Common
NSURL *url=[[NSBundle mainBundle] URLForResource:@"about" withExtension:@"html"];
//Method 1
[webView loadRequest:[NSURLRequest requestWithURL:url]];
//Method 2
NSString *HTML=[NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
[webView loadHTMLString:HTML baseURL:[NSURL URLWithString:[[NSBundle mainBundle] bundlePath]]];

Strangely, if I change the URL as follows, then both methods work (of course loading the string doesn't show css):

NSURL *url=[NSURL URLWithString:@"http://www.google.com"];

controllerWithTitle is defined in a category as follows:

-(UIViewController*) controllerWithTitle:(NSString*)title{
    UIViewController *vc=[[[UIViewController alloc] init] autorelease];
    vc.view=self;
    vc.title=title;
    return vc;
}
A: 

It turns out that the CSS was causing the entire page to not display!

Casebash