title: Managing views while integrating zxing for iPhone
body: <p>I am trying to integrate <a href="http://code.google.com/p/zxing/" rel="nofollow">zxing</a> in my already existing iPhone app. I have referred to the ScanTest example enclosed in the project download, and have succeeded in building and running the scanner.</p>
  
  <p>My problem lies in managing the views of the project to incorporate the scanner. Currently I have an already existing view controller(VC-A), which needs the scanner ability. I created a new view controller(VC-B) to launch the <code>ZXingWidgetController</code> scanner view. So the flow looks like the following:</p>
  
  <blockquote>
    <p>VC-A-> presentModalViewController(VC-B)->VC-B->
    presentModalViewController(ZXingWidgetController)</p>
  </blockquote>
  
  <p>Now as is in the ScanTest sample application, when the scanning is complete, a dissmissModalViewController is called from VC-B which dismisses ZXingWidgetController's view. The problem is whatever way I try, I am unable to dismiss VC-B to come back to VC-A. I have created a set of delegate methods to notify VC-A, when the scanning is completed/canceled. I get the scan data in those methods, but am unable to dismiss VC-B's view.</p>
  
  <p>I don't want to modify my already existing view controller VC-A, therefore I am unable to incorporate ZXingWidgetController directly in it, discarding VC-B altogether(cause it would require making VC-A a .mm file).</p>
  
  <p><strong>EDIT:</strong>
  Now I am doing away with ZXingWidgetController's modal, altogether. Using this code in <code>viewDidLoad</code> on VC-B</p>
  
  <pre><code>//Create custom overlay
  OverlayView *scannerView = [[OverlayView alloc]initWithFrame:CGRectMake(27, 107, 267, 253) cancelEnabled:NO oneDMode:NO];
  scannerView.displayedMessage = nil;
  widController = [[ZXingWidgetController alloc]init ];
  
  //set the overlay of widController
  [widController setOverlayView:scannerView];
  
  QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
  NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
  [qrcodeReader release];
  widController.readers = readers;
  widController.delegate = self;
  [readers release];
  [scannerView release];
  NSBundle *mainBundle = [NSBundle mainBundle];
  widController.soundToPlay = [NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO];
  
  //Add scanner to the view
    [self.view addSubview:widController.view];
  </code></pre>
  
  <p>Now the camera view of ZXingWidgetController is not visible at all. Has anyone customized the overlay for Zxing? I don't seem to find any similar problem on SO.</p>