Customization of scanning page in zbar application - iphone

I am working on an application that scans the QR codes.When the scan button is clicked,it goes to the generic full page camera view.But i need to customize that page so that a logo must be shown at the bottom and a button at the top.the scanning area should be in between these two.How can i implement the?anyone have answer?the code i am using is given below
- (IBAction) scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
}

You can set property cameraOverlayView of ZBarReaderViewController. Some docs is here.
ZBarReaderViewController* reader = [[ZBarReaderViewController alloc] init];
reader.cameraOverlayView = yourCustomView;
To change tabBar you can add your subview.
You can access it using this:
UIView* subView1 = [reader.view.subviews objectAtIndex:2];
UIView* tabBar = [subView1.subviews objectAtIndex:0];
Now you can customize tabBar in the way you like.

Related

ZBarReader QR Code detection time

In my app i'm using ZBarReader, and i can able to detect the QRCode and BarCode using the code
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology:0 config:ZBAR_CFG_ENABLE to:0];
[scanner setSymbology: ZBAR_QRCODE
config: ZBAR_CFG_ENABLE
to: 1];
reader.tracksSymbols=YES;
reader.readerView.zoom=1.0;
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
But it detects the code only when i make my camera much closer to the barcode, it's not detecting when i keep my camera little far from barcode Is there any property to scan the code very Quickly even when i have camera far from barcode..
Basically Zbar reader depends on the camera resolution of the device but still try using
reader.readerView.session.sessionPreset = AVCaptureSessionPreset1280x720;
adjust AVCaptureSessionPreset1280x720 .May this helps.

scan barcode(generated using ZBar SDK) using iPhone simulator?

I want to test my barcode scanner using iPhone Camera.
I'm using ZBar SDK for my barcode scanning.
I have a scan button for this.When I click on Scan button,its showing me the message,"Camera simulation, tap and hold with two finger to select image".When I'm doing this,its showing "No photo" in another view.
I'm doing like this:
-(IBAction) scanButtonTapped
{
//Barcode reader that scans from camara feed
reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
//disable rarely used I2/5 to improve performance
[scanner setSymbology:ZBAR_QRCODE config:ZBAR_CFG_ENABLE to:0];
reader.readerView.zoom = 1.0;
//present and release the controller
[self presentModalViewController:reader animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//get decode result
id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for (symbol in results) {
break;
}
resultText.text = symbol.data;
resultImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
[reader dismissModalViewControllerAnimated:YES];
}
I'm trying to scan QR code.
Could any one plaese tell me how can I select an barcode image and scan it using simulater?
Thanks.
You can't. Camera is only available on device.

Button action is not perfect when it is first tapping?

I have an application in which I have a UIView (Zbarsdk reader view) in my xib. When a button is tapped, that view should be loaded. But actually when the button is tapped, the previous view is loading at first (from which I came to my view). But after running once then again running then the correct view is loading? (From login I came to home. In home I have one button to load one view that is separate in my xib, but when running first it is loading the login screen again. But without deleting that build when u run again that code in simulator is loading that correct view). Does anybody know why?
- (IBAction) tappressed
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
[reader willRotateToInterfaceOrientation:UIInterfaceOrientationPortrait duration:0];
//[self.readerView willRotateToInterfaceOrientation:orient duration:0];
//reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationLandscapeRight);
// [reader shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
//reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft);
reader.sourceType=UIImagePickerControllerSourceTypeCamera;
// UIImageView *overlayImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"overlaygraphic.png"]];
//overlayImage.bounds=CGRectMake(50, 75, 320-100, 480-150);
reader.cameraOverlayView=cameraOverlay;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController:reader animated:YES];
// [self.view addSubview:reader.view];
[reader release];
}

ZBar SDK orientation Issue in Ipad?

I have an IPAD application which is supporting only in landscape mode. In which i wanted to use ZbarSDK for reading bar codes,i created a view in my view controller then load it with background of the readerviewcontroller.working fine in iphone.But in ipad with this orientations it is behaving strage,like loading in portrait mode,etc.I am using this but no luck.reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationLandscapeRightcan anybody help me how to use this sdk correctly in ipad with landscape orientations?
I have just had problems with the embedded reader view and read that a call to setNeedsLayout was missing on rotation, not sure if it will help someone but here is what fixed my problems
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient duration: (NSTimeInterval) duration
{
[self.readerView willRotateToInterfaceOrientation:orient duration:duration];
[self.readerView setNeedsLayout];
}
i think use bellow code may this help you...
ZBarReaderViewController *reader = [ZBarReaderViewController new];
[reader shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
hope,this help you..
:)
Works fine for me. Our iPad app supports only Landscape orientation:
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
ScanOverlay overlayController = [[ScanOverlay alloc] initWithNibName:#"ScanOverlay" bundle:nil];
reader.cameraOverlayView = overlayController.view;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
reader.supportedOrientationsMask = UIInterfaceOrientationMaskLandscape;
reader.wantsFullScreenLayout = YES;
reader.showsZBarControls = NO; //If we don't set this to NO, the overlay may not display at all
reader.tracksSymbols = YES;
[overlayController willRotateToInterfaceOrientation:YES duration:0.5];
// ADD: present a barcode reader that scans from the camera feed
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
//Show the scanner view
if([self respondsToSelector:#selector(presentViewController:animated:completion:)]){
[self presentViewController:reader animated:YES completion:^(void){}];
} else if([self respondsToSelector:#selector(presentModalViewController:animated:)]) {
[self presentModalViewController:reader animated:YES];
} else {
NSLog(#"Error! Can't present the View Controller");
}

iPhone getting value to two different textfields from single method

Using the below code, the issue is I have two buttons and two textfields but I am getting the qrcode value using single method. How can i use it for two textfields
- (IBAction) keyScanButtonTapped
{
NSLog(#"TBD: scan barcode here...");
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
// present and release the controller
[self presentModalViewController: reader animated: YES];
[reader release];
}
-(void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
// EXAMPLE: do something useful with the barcode data
deviceKey.text = symbol.data;
// EXAMPLE: do something useful with the barcode image
resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
}
Do you simply want to connect two different buttons to this same function? That is no problem just go into interface builder and connect both buttons to this method. You can see this question on how to connect buttons in interface builder
How can I connect "File's Owner" with a button in a Toolbar?
when the callback function is called you can identify which button called the function in such a manner
-(void)buttonPressed:(id)sender{
//find out which button was pressed
UIButton * pressed = (UIButton*) sender;
NSInteger tag = pressed.tag;
}
the tags are defined in the interface builder, just make sure that they are different for the two buttons and you are good to go.