Search code examples
iphoneiosbarcode-scannerzbar-sdk

ZBarReaderView with custom size from storyboard moving after start is called


i've got a ZBarReaderView created from storyboard with 216x20 px which is shown as roughly 230x50 px because ZBarReaderView doesn't take it's size too serious... It all works very well, however it behaves really strange when I call start on that readerView. It starts the cam but then in maybe half a second the readerView zooms a bit and the camera picture inside the readerView moves down and then up again. It's not terrible but it look kinda bad. Anyone got any ideas what might be causing this and how to solve it? Maybe the sdk has some sort of hidden callback for the readiness of the scanner, i could hide it until the scanner says it's ready and then show the scanner like .5 seconds later...

barcodeReader is the iboutlet to the ZBarReaderView and scannerLoading is an iboutlet to a uiactivityindicatorview which is animating until the scanner is loaded. These are the only settings which are changed from default, except the frame which is set in the storyboard of course.

[barcodeReader setReaderDelegate:self];
[barcodeReader setAllowsPinchZoom:false];
[barcodeReader start];

/* this works because [barcodeReader start] blocks ui updates until the scanner
   is running, i know it's not a good solution but since there doesn't seem to 
   be a callback or delegate method like scannerDidStart or something it seems 
   to be the only way... */
[scannerLoading stopAnimating]; 

Thanks for your help!


Solution

  • I just posted an answer to a retaliated question:

    ZBarReadview with custom size from StoryBoard,but when it's called,it's size is not I set

    Maybe the answer also solves your problem.

    In short:

    When using Interface Builder or Storyboard to create a view and assign the ZBarReaderView to it, you have to check "Clip Subviews" in the properties for the camera image to keep the size of the view.