0

I'm working with ZBar and am trying to add a subview to show a searching UIActivityIndicatorView after I scan a barcode and before my new view is ready (slow web lookup, etc). Here is the code:

- (IBAction)scanImage{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;

ZBarImageScanner *scanner = reader.scanner;
// (optional) additional reader configuration here
[scanner setSymbology: ZBAR_ISBN13 & ZBAR_ISBN10
               config: ZBAR_CFG_ENABLE
                   to: 1];

// present and release the controller
[self presentViewController:reader animated:YES completion:NULL];
}

- (IBAction)existingImage {
ZBarReaderController *reader = [ZBarReaderController new];
reader.readerDelegate = self;
reader.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[reader.scanner setSymbology: ZBAR_ISBN13 & ZBAR_ISBN10
                      config: ZBAR_CFG_ENABLE
                          to: 1];

[self presentViewController:reader animated:YES completion:NULL];
}

- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
[reader dismissViewControllerAnimated:YES completion:NULL];

[reader.view addSubview:loading];
...

The problem is with the last two statements. The reader view controller doesn't get dismissed until later in the cold block when I perform a segue, and the "loading" subview (setup earlier in the code) doesn't get displayed. I can play with the code to show that loading is legit but I can't get it to appear when I want. The screen just shows the camera view or the picture of the existing image, I can see all the segue setup activity happening in the console log, and then the view updates with my segue'ed view controller. FWIW I'm requiring iOS6 so that's why I'm using dismissViewControllerAnimated: instead of dismissModalViewController: but I tried that anyway and it didn't work.

Any suggestions are greatly appreciated!

MikeMilzz
  • 79
  • 8
  • Why your action method is missing input argument.? The standard format is this as far as I know is like this `- (IBAction)scanImage:(id)sender`. Right? – hp iOS Coder Dec 13 '12 at 05:59
  • I copied that straight out of the sample doc, so I doubt that's causing me problems. http://zbar.hg.sourceforge.net/hgweb/zbar/zbar/file/38e78368283d/iphone/examples/ReaderSample/ReaderSample/ReaderSampleViewController.m – MikeMilzz Dec 13 '12 at 15:08
  • First check, by putting **breakpoints**, if the control is reaching all the `- (IBAction)` methods you wrote. If control is not reaching then check if the outlets are connected properly. If outlets are connected then pls change the method declaration as suggested by me in prev comment – hp iOS Coder Dec 14 '12 at 05:02
  • I added the :(id)sender in but it didn't change anything. I've used breaks and it does get to all the lines of code. It just seems like there is a delay in my UIImagePickerController from being dismissed. – MikeMilzz Dec 15 '12 at 04:28

0 Answers0