Я использую Zbar SDK и хочу отсканировать QR-код и штрих-код в моем определенном фрейме, но он сканирует в любой части экрана, не в моем определенном фрейме, так где я делаю ошибку?Я хочу сделать сканирование таким образом в моем определенном кадре.
http://www.visionsmarts.com/products/VSBarcodeReader/VSBarcodeReader.html
вот мой код.
-(void)displayMe{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.showsZBarControls=NO;
//////////////black area/////////////////////////
UIImage *image1 = [UIImage imageNamed:@"blackscreen.png"];
UIImageView *imageLogo1 = [[UIImageView alloc] initWithImage:image1];
imageLogo1.frame = CGRectMake(0, 0, 320, 480);
cancelLabel =[[UILabel alloc]initWithFrame:CGRectMake(0,420, 320, 60)];
cancelLabel.backgroundColor = [UIColor blackColor];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setFrame:CGRectMake(100,420, 100, 60)];
[btn setTitle:@"Cancel" forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
btn.backgroundColor=[UIColor blackColor];
[btn addTarget:self action:@selector(back)
forControlEvents:UIControlEventTouchUpInside];
[cancelLabel bringSubviewToFront:btn];
[imageLogo1 addSubview:cancelLabel];
[imageLogo1 setUserInteractionEnabled:YES];
[imageLogo1 addSubview:btn];
//reader.cameraOverlayView = btn;
///////////////line/////////////////////////////
UIImage *image = [UIImage imageNamed:@"ScannerKitLaser@2x.png"];
UIImageView *imageLogo = [[UIImageView alloc] initWithImage:image];
imageLogo.frame = CGRectMake(40, 240, 230, 10);
[imageLogo1 addSubview:imageLogo];
///////////////Configure reader///////////////////////////////
reader.cameraOverlayView = imageLogo1;
//reader.cameraOverlayView.frame=CGRectMake(40, 240, 230, 30);
//imageLogo.frame = CGRectMake(0, 0, image.size.width, image.size.height);
//imageLogo.center = CGRectMake(320/2, 460/2, image.size.width, image.size.height);
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 1];
ZBarCaptureReader *cap=[[ZBarCaptureReader alloc]init];
//cap.scanCrop=CGRectMake(300, 400, 230, 200);
cap.scanCrop=CGRectMake(100, 160, 50,60);
//cap.cameraOverlayView.frame=CGRectMake(40, 240, 230, 30);
[self presentModalViewController: reader
animated: YES];
[reader release];