0

I want to use the function of QRCodeReader in my app.
My app is developed in cocos2d-x.
I think I have to use native code (Android/iOS).
There are some ways to use QRCodeReader in iOS. (ZXing,ZBar,and the QR function in iOS (http://www.renaudpradenc.com/?p=453))

But my code in any way doesn't work well.. Anyone know how to do?

It might not related to this question, the following code can call Camera in iOS.

void NativeLauncher::ShowCameraView(){
    AppController  *appController = (AppController *)[UIApplication sharedApplication].delegate;

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

    imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;

    [appController.viewController presentModalViewController:imagePicker animated:YES];

} 
lp6m
  • 65
  • 1
  • 2
  • 7

4 Answers4

1

Here's a great tutorial in Objective C:

How To Scan QR Code Using AVFoundation Framework

and here's one in Swift:

QR Code Swift tutorial

Jeffrey Berthiaume
  • 4,054
  • 3
  • 35
  • 45
1

Sorry for the late answer.

You´ll probably think in 2 strategies, since there a no native cocos2d-x support for QRCode decoding.

1) Develop Objective-C -> C++ wrapper

Implement AVFoundationFramework methods in the objc side and also decoding helpers for images that you´ll use Call those methods on a C++ wrapper class in cocos2d-x project (check Carlo´s Google Game Services as start point: https://github.com/cpinan).

2) Use any QRCode C++ Library

There are many QRCode Decoders in c++, but you need to make sure that libraries targeting archtectures that you need. (e.g https://github.com/zxing/zxing)

Hope it helps. Cheers!

alemao13ea
  • 101
  • 1
  • 2
0

If your App is for above iOS 7, you can use AVCaptureMetadataOutputObjectsDelegate to implement QRCode scan inside your App. If you don't know how to implement AVCaptureMetadataOutputObjectsDelegate here is a Simple implementation for you.

https://github.com/dilumnavanjana/MetaQR

Add MetaQR.h & .m files to your Project & Add this code,

MetaQR *metaQR = [[MetaQR alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
metaQR.delegate = self;
[self.view addSubview:metaQR];

This delegate method will gives you the data of the QRCode

-(void)capturedMetaOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
DilumN
  • 2,889
  • 6
  • 30
  • 44
0

For the Deployment Target of 7.0 or above, you can use AVFoundationFramework for reading the Qr code.

Here is a tutorial for doing this : http://www.ama-dev.com/iphone-qr-code-library-ios-7/

This question is also answered here : QR Code Scanning in ios application

Community
  • 1
  • 1
Jaideep Nagra
  • 519
  • 3
  • 13