Tuesday, 10 January 2012

Loading local HTML file via IBAction in WebView


hi
i'm trying make button load local html file in webview on osx app. current code is:

code:
- (ibaction)returnhome {      [webview setuidelegate:self];       nsurl *url = [[nsbundle mainbundle] urlforresource:@"index" withextension:@"html"];      nsstring *html = [nsstring stringwithcontentsofurl:url encoding:nsutf8stringencoding error:nil];      nsurl *baseurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]];      [[webview mainframe] loadhtmlstring:html baseurl:baseurl];  }
and not load file "index.html". i've being trauling forums, can't see similar, though know must quite simple. have ideas what's wrong code?

sorry if in wrong place - wasn't sure put it.

in advance,

sam
 

google
[webview loadrequest:[nsurlrequest requestwithurl:[nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:mad:"index" oftype:mad:"html"] isdirectory:no]]];
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment