我想知道是否可以从 iOS 设备的硬盘驱动器运行 HTML 页面,仅使用 Objective-C 作为 HTML 页面的视图端口,并将 HTML 页面作为应用程序的实际界面。这可能吗?
谢谢,
奥迪努尔夫
我想知道是否可以从 iOS 设备的硬盘驱动器运行 HTML 页面,仅使用 Objective-C 作为 HTML 页面的视图端口,并将 HTML 页面作为应用程序的实际界面。这可能吗?
谢谢,
奥迪努尔夫
为 IOS 创建一个包含以下内容的文件:
#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
(我直接从《HTML5 for IOS and Android: A Beginner's Guide》一书中得到了这一点[第 388-390 页])
这就是你为安卓做这件事的方式。
希望这可以帮助!
是的,有可能。您需要对 UIWebView 进行子视图,然后加载指向本地目录中的 HTML 文件而不是 Web URL 的请求。您的所有网页都需要添加到应用程序包中。
UIWebView *webview;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"page_name" ofType:@"html"]isDirectory:NO]]]
是的,有可能。但是,要小心,苹果有时会拒绝它。这就是我们所说的Web 应用程序。
正如马特指出的那样,看看 PhoneGap 或 Sencha Touch
听起来http://phonegap.com是您正在寻找的。
我曾在 Android 上使用过 phonegap,对此我印象深刻。没有用 IOS 尝试过,但这里是 PhoneGap的链接