2010-09-29 5 views
1

Pour une raison quelconque, la première méthode n'affiche rien, tandis que le second fait:fonctionne stringWithContentsOfFile, mais requestWithURL ne

//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]; 

D'autre part, j'ai aussi essayé de le charger en utilisant une URL comme bien. De même, la première méthode n'affichait rien tandis que la seconde l'a fait.

//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]]]; 

Étrangement, si je change l'URL comme suit, puis les deux méthodes de travail (chargement de cours la chaîne ne montre pas css):

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

controllerWithTitle est défini dans une catégorie comme suit:

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

Répondre

0

Il s'avère que le CSS faisait que toute la page ne s'affichait pas!

Questions connexes