HTML 5 + iOS - 创建混合应用程序 [英] HTML 5 + iOS - creating hybrid applications

查看:184
本文介绍了HTML 5 + iOS - 创建混合应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用HTML 5将我的本地iOS应用程序转换为混合应用程序。
进行研究后,我最终以 jQuery mobile + phoneGap。



我的问题是


  1. 可以在单个$ b中混合html 5和原生iOS功能$ b查看?例如,我可以使用html文本字段获取值,并使用
    它使用iOS选择器做一些转换。

  2. 可以从html浏览到一个原生xib

感谢您的合作! '。如果您要在网页视图中插入原生iOS选择器 ,这是不可能的。正如nhahtdh所提到的,您添加的任何本机iOS视图将放置在您的HTML5 UIWebView的顶部。要执行这样的任务,您需要通过Javascript来掌握通信。有关如何轻松地在ObjC和Javascript之间进行通信以传递值的技术,请参见 https://github.com/diy/conduit 这样的框架


  • 可以通过设置iOS来从HTML页面(例如点击链接)执行导航应用程式观看特定网址要求,并根据这些要求执行一些动作。我使用NSURLCache为此目的。所以,如果你想在你的HTML链接触发一个xib文件的加载,你可以通过NSURLCache查看该URL的请求,并加载你的xib当你看到它。 此链接帮助我掌握了这项技术。


  • 我的理解是,所有的混合iOS + HTML框架都使用这种一般的技术来建立类似于REST的一组URL请求,可以通过NSURLCache类系统和触发器来解析基于这些URL的本机事件。虽然使用现有的框架可能会节省一些时间,但实现自己并不难以实现更简单的功能。



  • 这些大框架可能会帮助您更高级地缓存HTML资源。

    I am trying to convert my native iOS app into a hybrid app using HTML 5. After doing a research I ended up with jQuery mobile + phoneGap.

    My questions are

    1. Is it possible to mix html 5 and native iOS features within a single view? For example can I use html text field to get the value and use it to do some conversion using iOS picker.
    2. Is it possible to navigate to a native xib from an html page?
    3. And finally is there any better solution to create a hybrid app?

    thanks in advance

    解决方案

    1. Yes, you can mix native iOS features within a single 'view'. If you're looking to insert a native iOS picker into the web view, that's not really possible. As nhahtdh mentioned, any native iOS views you add will be placed on top of your HTML5 UIWebView. To perform tasks like this, you'll need to master communication via Javascript. See frameworks like https://github.com/diy/conduit for techniques on how to easily communicate between ObjC and Javascript to pass values back and forth between native and HTML.

    2. It is possible to perform navigations from HTML pages (when clicking on links, for example), by setting up your iOS app to watch for specific URL requests, and perform some action based on them. I've used the NSURLCache for this purpose. So, if you wanted a link in your HTML to trigger a load of a xib file, you can watch for that URL to be requested via the NSURLCache, and load your xib when you see it. This link helped me master this technique.

    3. It is my understanding that all of the hybrid iOS + HTML frameworks use this general technique of establishing a REST-like set of URL requests that can be parsed out by a NSURLCache-like system and trigger native events based on those URLs. While using an existing framework may save you some time, it's not that difficult to implement yourself for more simple functionality. The big frameworks might help you along with more advanced caching of the HTML resources, however.

    这篇关于HTML 5 + iOS - 创建混合应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆