最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - HTML5 and javascript in xcode - Stack Overflow

programmeradmin2浏览0评论

I'm quite new to xcode, because I mostly work with JS and HTML5. I've decided to create a simple webview app that enables me to work with JS and HTML5 (going to put it on Github asap)

Now my question is about accessing certian iPhone features that I cannot use in Safari or Chrome (the reason why I'm creating this). So the question is: is this possible? for example, I can't access the camera (as a fullscreen background I mean) in an iOS browser, but can I use it in webview?

I'm quite new to xcode, because I mostly work with JS and HTML5. I've decided to create a simple webview app that enables me to work with JS and HTML5 (going to put it on Github asap)

Now my question is about accessing certian iPhone features that I cannot use in Safari or Chrome (the reason why I'm creating this). So the question is: is this possible? for example, I can't access the camera (as a fullscreen background I mean) in an iOS browser, but can I use it in webview?

Share Improve this question asked May 29, 2014 at 22:01 Bob van LuijtBob van Luijt 7,59815 gold badges62 silver badges107 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You need any method of municating between UIWebView and the containing app. There are libraries out there that do just that, some better some less. In case you do not want them... So to outline the techniques to do that:

  • App talking to the webView - using [webView stringByEvaluatingJavaScript:...]
  • Webview talking to the app - using url directives. Which is essentialy window.location = ... with custom fake urls, and then parsing the NSURLs in the delegate method webView:shouldStartLoadWithRequest:navigationType: and of course returning NO to prevent actually navigating to your fake urls.

If you find that you are missing consecutive URL requests, you could write a JS function that takes the URLs, puts them all in an array, pops one by one and sending them to the browser in a setTimeout(..., 0).

You need to use something like this - Cordova or PhoneGap ( Both are the same thing )

"Apache Cordova is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript."

Here is a description of all the device features cordova or phonegap allow you to use - Plugin API's

Yes, is it possible, but using a web app container like Phonegap.

If you need more info how install it visit this web.

发布评论

评论列表(0)

  1. 暂无评论