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!