Html 使用 UIWebView 构建 HTML5 iOS 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4249816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Building an HTML5 iOS app with UIWebView
提问by Trey Bean
I have a client who suggested we simply wrap an HTML5 app as a native iOS app by just creating a UIWebView and offloading all of the application-logic to the HTML5 app. This would allow us to have a "native" iOS app and a good mobile app for other devices.
我有一个客户建议我们只需创建一个 UIWebView 并将所有应用程序逻辑卸载到 HTML5 应用程序,就可以将 HTML5 应用程序包装为原生 iOS 应用程序。这将使我们能够拥有一个“原生”iOS 应用程序和一个适用于其他设备的良好移动应用程序。
However, this strikes me as a little odd and I was wondering what the pitfalls of such a plan would be. Does anyone have any experience doing this?
然而,这让我觉得有点奇怪,我想知道这样一个计划的陷阱是什么。有没有人有这样做的经验?
Thanks, Trey
谢谢,特雷
回答by Empereol
Any pitfalls you would experience as a web app you are likely to still experience. Don't attempt to do any OpenGL sort of app but if it's more like a webpage then this should work out fine for you.
作为 Web 应用程序您可能会遇到的任何陷阱,您可能仍然会遇到。不要尝试做任何 OpenGL 类型的应用程序,但如果它更像是一个网页,那么这对你来说应该没问题。
However, using some frameworks out there you are likely to get a slightly "richer" experience in that you are able to access native phone tools that a web app isn't allowed to use (vibrate, GPS, etc.)
但是,使用一些框架,您可能会获得稍微“更丰富”的体验,因为您可以访问网络应用程序不允许使用的本机电话工具(振动、GPS 等)
Take a look at PhoneGap. They lack extensive documentation but there are quite a number of people using it and have already 'ran it through the gauntlet', you could say.
看看PhoneGap。他们缺乏广泛的文档,但有相当多的人使用它并且已经“通过了挑战”,你可以说。
All that said, if you don't want to deal with the marketplaces (iTunes, Android Marketplace, etc) you could always do an offline HTML5 app. Where the user goes to the webpage and it caches all the files that are required to run the app offline. This is a similar approach to what Googlewas doing with Google Voicewhen it was rejected from the iTunes store.
综上所述,如果您不想处理市场(iTunes、Android Marketplace 等),您始终可以做一个离线 HTML5 应用程序。用户访问网页的位置,它会缓存离线运行应用程序所需的所有文件。这是一个类似的方法是什么谷歌与做谷歌语音当它从iTunes商店拒绝。
回答by Dmitry Isaev
HTML5 features within a WebView are really great (and growing). You can do almost everything.
WebView 中的 HTML5 功能非常棒(并且还在不断增长)。你几乎可以做任何事情。
But if you want use some special features inaccessible via HTML5 (or include some 3rd-party ObjC libraries), you can setup a very simple interaction between ObjC and JavaScript.
但是如果你想使用一些无法通过 HTML5 访问的特殊功能(或包含一些 3rd-party ObjC 库),你可以在 ObjC 和 JavaScript 之间设置一个非常简单的交互。
回答by PKHunter
Trigger.io is an option too. Much better than Phonegap these days. Only adding as this page is heavily google-SEOed.
Trigger.io 也是一种选择。这些天比Phonegap好多了。仅添加此页面是大量 google-SEOed。