我正在写iphone应用程序,我想扫描二维码。我有二维码库来扫描二维码。现在我想给我的iPhone应用程序提供二维码扫描接口。
在安卓系统中,我可以使用SurfaceView来实现这一点,这是我们可以显示相机帧的视图。在Android中,有没有什么东西可以和iPhone中的surfaceview等价物呢?如果是这样,如何做到这一点。请给我一个教程或示例链接。
发布于 2013-01-22 20:04:40
- (IBAction)TakePicture:(id)sender {
// Create image picker controller
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
// Set source to the camera
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Delegate is self
imagePicker.delegate = self;
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
// Insert the overlay:
imagePicker.cameraOverlayView = overlay;
// Allow editing of image ?
imagePicker.allowsImageEditing = YES;
[imagePicker setCameraDevice:
UIImagePickerControllerCameraDeviceFront];
[imagePicker setAllowsEditing:YES];
imagePicker.showsCameraControls=YES;
imagePicker.navigationBarHidden=YES;
imagePicker.toolbarHidden=YES;
imagePicker.wantsFullScreenLayout=YES;
self.library = [[ALAssetsLibrary alloc] init];
// Show image picker
[self presentModalViewController:imagePicker animated:YES];
}创建一个UIView类并添加以下代码
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
// Clear the background of the overlay:
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
// Load the image to show in the overlay:
UIImage *overlayGraphic = [UIImage imageNamed:@"overlaygraphic.png"];
UIImageView *overlayGraphicView = [[UIImageView alloc] initWithImage:overlayGraphic];
overlayGraphicView.frame = CGRectMake(30, 100, 260, 200);
[self addSubview:overlayGraphicView];
}
return self;
}您也可以访问此链接:http://www.musicalgeometry.com/?p=821
发布于 2015-08-23 03:41:39
从iOS 7开始,二维码检测在iOS中很容易使用,诀窍是告诉AVCaptureMetadataOutput实例检测类型为AVMetadataObjectTypeQRCode的对象。
实时相机预览(如果你仍然想使用它,可以访问像素)在iOS中已经有很长一段时间了,使用AVCaptureVideoPreviewLayer最容易。
有关http://www.appcoda.com/qr-code-reader-swift/示例,请参阅此处
https://stackoverflow.com/questions/14456724
复制相似问题