iphone - stringWithContentsOfFile works, but requestWithURL doesn't -


for reason, first method doesn't display anything, while 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 other hand, tried loading using url well. similarly, first method didn't display while 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 change url follows, both methods work (of course loading string doesn't show css):

nsurl *url=[nsurl urlwithstring:@"http://www.google.com"]; 

controllerwithtitle defined in category follows:

-(uiviewcontroller*) controllerwithtitle:(nsstring*)title{     uiviewcontroller *vc=[[[uiviewcontroller alloc] init] autorelease];     vc.view=self;     vc.title=title;     return vc; } 

it turns out css causing entire page not display!


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -