1

I am facing some problem after integrating ZBar framework for scanning QRCodeRead on my apps. My client wants, QRCode Scanner will be in a fixed frame and must not be a PresentModalView. So I write code for fixed frame QRCode Scanner and added the reader.view on self.view, but it not working as presentModalViewController:reader. I don't know what is going wrong. I am not able to solve this issue. I have provided my code below and Sorry for my bad English.

This Code is working...

- (IBAction) scanButtonTapped
{
    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];
}

But this Code is not working...

- (IBAction) scanButtonTapped
{
    // Create new reader
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    [reader.scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
    reader.showsCameraControls = NO;
    reader.showsZBarControls = NO;
    [reader setWantsFullScreenLayout:NO];
    reader.showsHelpOnFail = NO;
    reader.showsZBarControls = NO;
    [reader.view setFrame:CGRectMake(20, 134, 280, 202)];

    [self.view addSubview:reader.view];
    [reader release];
}

Please help me and provide a solution.Thanks in advance.

Hristo Iliev
  • 72,659
  • 12
  • 135
  • 186
Lutful Kabir
  • 119
  • 6
  • I'm not sure, but it seems that you shouldn't release "reader" instance in second example. Try to keep the reference to reader within the parent view controller. And second, you wrote that it works in the first example and doesn't work in the second one. Can you describe the problem more carefully (app crashes, doesn't show the scanner, doesn't scan, etc). – RomanN Dec 12 '12 at 09:45

0 Answers0