Previous blog post using PHONEGAP development based on HTML5 application one: phonegap introduction I introduced how to download the source code from the PHONEGAP official website and launch the first application, today we put the application of phonegap a little change, Let him achieve several features that compare the Bull fork:
1. Start a Web page
2. Start the camera
3. Start positioning
The old ritual, before we do these things, let's talk about the original reason:
First of all, we look back at the last said, in fact, PHONEGAP application has a special webview, it is Cdvviewcontroller, about this class we described in detail, now we first understand what this class did, it is actually called the iOS device controller class , then how does he know that the user is going to call a device like the camera, that is, by parsing the HTML JS code.
phonegap himself defined some JS code, let these JS code with Cdvviewcontroller This class to interact, The role of Cdvviewcontroller is to judge the server-side HTML code, if it is normal HTML directly display, if encountered phonegap custom JS code "translated" into the code called iOS. OK, the concept is complete, if you do not understand, we start to look at the example below.
is the official demo application directory, we only need to run after the package can be found (, the extension of the app means that it is a Mac system application, but the actual situation, it is an iOS app, that is, the extension is an IPA, so you can change the format through itunes, this is not much to say, You know what that means.) After opening, see the following list:
can see the WWW folder in the application, under the two files, a JS file, an HTML
And look at the Appdelegate code in Xcode:
Self.viewController.wwwFolderName = @ "www"; Self.viewController.startPage = @ "index.html";
The meaning of these two sentences is to refer to the directory name and file name
If you change into
Self.viewController.startPage = @ "http://www.baidu.com";
Can be implemented to load the function of Baidu homepage, the effect is as follows:
It is obvious that Baidu first shows that there is no problem.
Next article, will give you to parse cordova.js this file, because this JS indicates all the operation of the iOS device JS code, and it interacts with Cdvviewcontroller, so the exception is important.