I was wondering whether one could run a HTML page from the iOS device's hard drive, using Objective-C only as a view port to the HTML page and having the HTML page be the application's actual interface. Is this possible to do?
Thanks,
Odinulf
I was wondering whether one could run a HTML page from the iOS device's hard drive, using Objective-C only as a view port to the HTML page and having the HTML page be the application's actual interface. Is this possible to do?
Thanks,
Odinulf
for IOS create a file with the following:
#import "WrapperViewController.h"
@implementation WrapperViewController
- (void) viewDidLoad
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullpath = [NSBundle pathForResource:@"index" ofType:@"htm" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL: [NSURL fileURLWithPath:fullPath]]];
}
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
return YES;
}
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
{
webView.scalesPageToFit = YES;
WebView.backgroundColor = [UIColor blackColor];
}
- (void) didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void) dealloc
{
[super dealloc];
}
@end
(I got this straight out of the book "HTML5 for IOS and Android: A Beginner's Guide" [page 388-390])
And this is how you would do it for android.
Hope this helps!
Yes it is possible. You need to subview a UIWebView and then load a request pointing to the HTML file in your local directory instead of a web URL. All of your web pages need to be added to the application bundle.
UIWebView *webview;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"page_name" ofType:@"html"]isDirectory:NO]]]
Yes it is possible. But, be careful, apple sometimes refuses it. This is what we call Web application.
As Matt points out, take a look at PhoneGap or Sencha Touch
I've worked with phonegap with Android and am impressed with it. Haven't tried it with IOS but here's the link PhoneGap