【问题标题】:Run HTML5/CSS3 in UIWebView在 UIWebView 中运行 HTML5/CSS3
【发布时间】:2012-01-30 13:23:52
【问题描述】:

我有一个无法解决的问题,我想运行Apple - HTML5 Showcase - Gallary

在我的 ipad 应用程序中的 UIWebView 中。

我尝试了一个本地 html 文件:

NSString *strr = [[NSBundle mainBundle] pathForResource:@"photo-gallery" ofType:@"html"];

NSString *str = [[NSString alloc] initWithContentsOfFile:strr encoding:NSASCIIStringEncoding error:nil];
NSLog(@"%@",str);
[webView loadHTMLString:str baseURL:nil];

还有一个服务器 html 文件,但它不起作用,谁能帮帮我,我想在 UIWebView 中显示一个 html5/css3。

提前谢谢。

【问题讨论】:

    标签: ipad html css uiwebview ios-simulator


    【解决方案1】:

    你好,你可以这样做

               UIWebView *aWebView = [[UIWebView alloc] initWithFrame:webFrame];
               //getthe path of the local html file
               NSURL *baseURL = [NSURL fileURLWithPath:fileNamePath];
    
               NSURLRequest *aRequest = [NSURLRequest requestWithURL:baseURL];
               //load the html file into the web view.
               [aWebView loadRequest:aRequest];
    
               //add the web view to the content view
               [view addSubview:aWebView];
    

    对于服务器 html,您只需跳过第二行,然后输入地址。

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      你可以看看phonegap。它是一个完整的框架,用于在具有本机功能的 UIWebview 中构建 html5 应用程序。

      见:http://www.phonegap.com

      【讨论】:

      • 我的应用程序中有另一个要求,所以我无法在 phonegap 中构建它,还有其他方法吗?
      • 当然还有其他方法,但是你可以在 phonegap 中做任何在普通的 Objective-c 应用程序中可以做的事情
      • 我要展示一个集成了 CRM 系统的 3d 模型,它是一个巨大的应用程序,我之前没有尝试过 phonegap,我用它做了一些项目,但我不熟悉phonegap,我只是想显示一个360全景图像,我试过panomagl但它不起作用,总是报错,你能把我放在正确的行吗?!
      猜你喜欢
      • 1970-01-01
      • 2014-10-08
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多