Hi, I am developing a QR code reader application and am experiencing so many problems when disabling ZBarReaderViewController. I have a view controller with a button that creates a reader and presents it.
- (IBAction)scanAction:(id)sender { ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; [reader.scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0]; reader.readerView.zoom = 1.0; // [self presentViewController:reader animated:YES completion:nil]; [self presentModalViewController:reader animated:YES]; }
Then, in the reader delegate, I do this (I commented out the lines of processing the results, but still getting the same error):
- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info { // id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; // // ZBarSymbol *symbol = nil; // NSURL *url; // NSString * textUrl; // // for(symbol in results){ // textUrl = symbol.data; // NSLog(@"%@",textUrl); // url = [NSURL URLWithString:textUrl]; // break; // } // // if (url != nil) { //// NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //// [self.webView loadRequest:requestObj]; // [self.urlLabel setText:textUrl]; // } // [reader dismissViewControllerAnimated:NO completion:nil]; [reader dismissModalViewControllerAnimated:YES]; }
and this is the error that I get randomly:
QR reader[10159:907] Warning: Attempt to dismiss from view controller <ViewController: 0x1ed4c930> while a presentation or dismiss is in progress!
Sometimes it scans and rejects without warning, but when I get this warning, the reader continues to scan, and the delegate is called again until more warnings are shown.
I tried some suggestions from other users having the same problem, but in my specific case this will not work:
- using offsetModalViewController instead of a modal view that is deprecated.
- surrounding the processing of results in the completion block of the rejectViewControllerAnimated method.
Thank you for reading:)
source share