2015-07-03 140 views
-2

在我的應用程序中,我需要生成一個QR碼,並且必須對其進行掃描才能得到包含在QR碼中的結果。我已經使用ZBAR SDK實現了QR碼掃描,但是我無法生成QR碼。我曾嘗試使用ZXING,但它不起作用。請建議任何SDK或任何可以通過的鏈接來實現它。我已經試過此鏈接以編程方式生成QR代碼

https://github.com/zxing/zxing

回答

0

使用CIFilter生成QR碼。

CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; 

[filter setDefaults]; 

NSData *data = [url dataUsingEncoding:NSUTF8StringEncoding]; 
[filter setValue:data forKey:@"inputMessage"]; 

CIImage *outputImage = [filter outputImage]; 

參見:https://github.com/shu223/iOS7-Sampler/blob/master/iOS7Sampler/SampleViewControllers/QRCodeViewController.m

+0

謝謝,我已經實現了它successfully.Can我按照我自己的意願定製的QR碼的圖像? –

+0

您可以使用'[UIImage drawInRect:]'繪製自定義的QR碼圖像。請參閱https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/ – user3480295