that's easy! I tried to load a local webarchive in Big5 (same as
PhoneGap) and it worked. The only thing to be aware of is not to
include post loading stuff in the page, if you want to remain
completely offline.
So, how does it work?
1 You surf to your page via Safari
2 Go to "save as" and choose "webarchive"
3 Add the webarchive to your PhoneGap bundle
The code in PhoneGap has to be something like:
NSString *urlPathString;
NSBundle * thisBundle = [NSBundle bundleForClass:[self class]];
if (urlPathString = [thisBundle pathForResource:@"demo"
ofType:@"webarchive"]){
NSLog(@"my app: loading local url %@", urlPathString);
[webView loadRequest:[NSURLRequest
requestWithURL:[NSURL fileURLWithPath:urlPathString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:20.0
]];
}
Dirk
Just drag and drop the whole folder of your WebApp from finder to
XCode Resources. Make sure that "Create Folder References for any
added folders" is selcted, because otherwise Groups are created which
do not result into subfolders. So lets say you added a folder called
"webapp", you may access it like this:
if (urlPathString = [thisBundle pathForResource:@"index"
ofType:@"html" inDirectory:@"webapp"]){
NSLog(@"my app: loading local url %@", urlPathString);
[viewController.gWebView loadRequest:[NSURLRequest
requestWithURL:[NSURL fileURLWithPath:urlPathString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:20.0
]];
}
That's it. It is so simple, I am really surprised :)
Dirk
Sorry, the example was based on Big Five. For PhoneGap you have to
modify this file:
http://github.com/sintaxi/gap/tree/master/Classes/GlassAppDelegate.m
This part:
if (urlPathString = [thisBundle pathForResource:urlFileName
ofType:@"txt"]){
NSString * theURLString = [NSString
stringWithContentsOfFile:urlPathString];
NSURL * anURL = [NSURL URLWithString:theURLString];
NSURLRequest * aRequest = [NSURLRequest requestWithURL:anURL];
[webView loadRequest:aRequest];
}
has to be replaced by this:
if (urlPathString = [thisBundle pathForResource:@"index" ofType:@"html"
inDirectory:@"webapp"]){
[webView loadRequest:[NSURLRequest
requestWithURL:[NSURL fileURLWithPath:urlPathString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:20.0
]];
}
I haven't tested it. But that's more or less the idea.
The url.txt file is not needed any mo
> Also, if you don't mind, could you host a sample of your project just
> to help.
> Thanks in advance I really appreciate. I'm so excited by your
> discovery, congratulations, and thank you for the effort!
Okay, I will try to publish a recent version of Big Five somewhere. But
this may take until Monday, because I will not publish it totally to the
public because of the Apple NDA. I will keep you updated.
Dirk
Thats a good example. I asked the developer of the WebApps.Net tool to
implement something similar ;)
BTW: Does someone know other good frameworks like Dashcode and
WebApps.Net? Dashcode is a little bit limited if you really need to
mimic an iPhone App with toolbars etc. What are you using?
Dirk
L.