objective c - OS X Web View App - Won't Load Local .html Web Page -
i have next code in appdelegate.m file opens google when open app. trying alter open .html web page copied xcode project not working. using xcode 4.5.2.
the code works open google is:
@implementation mdappdelegate - (void)applicationdidfinishlaunching:(nsnotification *)anotification { nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://www.google.com"]]; [self.webview.mainframe loadrequest:request]; } i tried changing (so load test.html file set in project folder app comes blank now). missing?
@implementation mdappdelegate - (void)applicationdidfinishlaunching:(nsnotification *)anotification { nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@"test.html"]]; [self.webview.mainframe loadrequest:request]; }
as long test.html copied @ root of project (make sure it's copied final app bundle, huh? - check build phases) can load web view using code :
nsstring *path = [[nsbundle mainbundle] pathforresource:@"test" oftype:@"html"]; nsurl* fileurl = [nsurl fileurlwithpath:path]; nsurlrequest* request = [nsurlrequest requestwithurl:fileurl]; [self.webview.mainframe loadrequest:request]; objective-c cocoa webview
No comments:
Post a Comment