Cordova (PHONEGAP) use (IOS)

Source: Internet
Author: User

1, Cordova Description:

Cordova provides a set of device-related APIs that enable mobile apps to access native device features, such as cameras, microphones, and so on, with JavaScript. Cordova also provides a unified set of JavaScript class libraries, as well as native background code related to the devices used by these class libraries. Cordova supports the following mobile operating systems: IOS, Android,ubuntu phone OS, Blackberry, Windows phone, Palm WebOS, Bada and Symbian.

Cordova is an open source project that has been contributed to Apache, is the core code extracted from the PhoneGap, is the core engine that drives phonegap. You can think of him as a relationship like WebKit and Google Chrome.

Official Instructions Document official Common command document 2, installation (terminal)
$ sudo npm install -g cordova

Use after installation cordova help if the following problems occur:

Do the following: (Resolve the problem connection)

sudo chown -R $USER /usr/localsudo chmod -R 0775 /usr/localnpm install -g cordova
3. Create an iOS project (terminal)
$ cd ~/Desktop/$ cordova create hello com.example.hello HelloWorld (Desktop路径下生成“hello”目录)$ cd hello$ cordova platform add ios (下载iOS相关资源)

Desktop/hello/platforms/ios/ HelloWorld.xcodeproj You can open the project under

4. Create an iOS project that Cordova call device albums

On 3 the basis of the established project

cd ~/Desktop/hello$ cordova plugin add org.apache.cordova.camera (下载cordova调用设备相册相关资源)$ cordova plugin add org.apache.cordova.media-capture$ cordova plugin add org.apache.cordova.media$ cordova plugin add org.apache.cordova.file (下载cordova调用访问设备文件资源)$ cordova plugin add org.apache.cordova.file-transfer

The next step is to implement the call Device album function, you can load the local JS, HTML files to implement, or you can include the call Device album Dynamic Web page. The first implementation of the local JS, HTML file features: will be downloaded after the index.html replacement project hello/platforms/ios/www/ index.html , will be downloaded after the phonegap.js entry Project project, the Real machine run:

Click Gapture Photo :

Because the company project, can not open the Dynamic Web page link, but I personally test the call Device album Dynamic Web page is no problem.

Implementation code: In the inheritance of the CDVViewController ViewControllerViewDidLoad

- (void)viewDidLoad {    [super viewDidLoad];    NSURLRequest *rq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"dynamic_camera_url"]];    [self.webView loadRequest:rq];}
5. Implant Cordova to an existing iOS project1. Create a CordovaDemo new Xcode project named2. Enter hello/platforms/ios/ :

CordovaLibto drag a folder into the CordovaDemo :

Then www drag the folder into CordovaLib : ( Added folders select as Create folder references )

will be HelloWorld in the config.xml and Plugins (no this file, can't take pictures!) ), drag into CordovaLib :

3. Code writing:

Will ViewController inherit from CDVViewController :

4, the operation error, add a <Foundation/Foundation.h> frame can:

5, the realization calls the device album function "创建cordova调用设备相册的iOS项目" , the reference6, Fix home!! Final Project6, the project encountered problems:1, the Cordova Project archive, prompted "Cordova/cdvplugin.h ' File not found" failed

Add $(OBJROOT)/UninstalledProducts/include to BuildSettings->Header Search Paths resolve the problem connection

Cordova (PHONEGAP) use (IOS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.