Brothers, I am back again!
1. What is PhoneGap
One of my clients had a requirement: to develop a mobile application, but not to use it in a cost-effective way, but to make a web-like application. In this way, we only need to access the Web page of their company's application in the browser to realize the basic functions of the localization application. But one problem is that, for security reasons, Android,ios does not provide access to devices such as cameras, GPS positioning, etc., via a browser called mobile devices (part of iOS). In order to realize this function, PhoneGap is a super lovely thing to produce.
If you have ever done iOS or Android development, you should know that both systems provide a view class like WebView, and you can understand that TA is simply a browser. And PhoneGap is a complex webview-based browser. Now you know it.
2. What is HTML5
Once someone has done such a prediction: The computer will not have the concept of software, but after the boot, the computer to start a browser, and then this "omnipotent" browser can input Baidu website to find content, you can enter the game site, directly play the game, you can open the computer camera to achieve the photo, can be realized .... Anyway, this browser is an omnipotent stuff.
But a little bit of HTML programming based friends know that HTML predefined tags are limited, even watching video by adding plug-in "Adobe Flash" implementation, it can be said that the traditional HTML is such slag. But the appearance of HTML5 completely changed this situation, it can customize the label, that is, we can write a label ourselves, the function of this label can be our own, to achieve the function of photography and other natural. is not feeling very flashy, think about is not a little chick frozen!!!!
3. Open our first PhoneGap program
The front said so many people may still be a little confused, the following we began to write code intuitive, Ok,let ' s go!
Login website: http://phonegap.com/(Download PhoneGap page: http://phonegap.com/install/)
After downloading, we begin to write the first PhoneGap-based program:
Version 1.iOS
Double-click the file "Cordovatests.xcodeproj" to open the PhoneGap project, you can find that there are three project,
These three project are:
Cordovalib:phonegap library file, build static library after compiling. a file
Cordovalibtest: Unit test, no more.
Cordovalibapp, this project is the application we want to run, we bulid this project
You can see the following effects:
Note: If you encounter the following error:
Undefined Symbols for Architecture i386:
"_objc_class_$_cmmotionmanager", referenced from:
Objc-class-ref in LIBCORDOVA.A (CDVACCELEROMETER.O)
Ld:symbol (s) not found for architecture i386
Clang:error:linker command failed with exit code 1 (use-v to see invocation)
We just need to add the following libraries to the library file:
So, our first PhoneGap program was so pleasant to run through.
Next, I'm going to take you through the analysis of this application