Zbar SDK and ios7/xcode 5 - App is reaching 100% cpu use and memory more than 100MB

前端 未结 6 982
我寻月下人不归
我寻月下人不归 2020-12-28 09:48

We are using Zbar bar code reader from last 2 years. With iOS 7 and Xcode 5, after scanning 5 bar codes the app is reaching 100 % cpu use for iOS 7 device(I can see that in

6条回答
  •  萌比男神i
    2020-12-28 10:15

    After seeing the same issue,

    I moved from

    ZBarReaderViewController

    to

    ZBarReaderView

    The disappointing part of this, though, is if you are using features like Overlay in the ZBarReaderViewController, you have to recode how that all works and you have to implement things like starting and stopping the scanner, manually.

    But essentially, you need something like this in your IBAction:

    ZBarReaderView *reader = [ZBarReaderView new];
    [self.view addSubview:reader];
    
    reader.readerDelegate = self;
    reader.tracksSymbols=YES;
    
    ZBarImageScanner *scanner = reader.scanner;
    
    reader.tag = 99999999;
    

    // the important part here is to START the scanning

    [reader start];
    

    Also, remember to change your delegate in your header to ZBarReaderViewDelegate

    Also, the delegate "method" that gets called, at least in my code, is now (versus the imagePickerController)

    -(void) readerView: (ZBarReaderView*) view
            didReadSymbols: (ZBarSymbolSet*) syms
            fromImage: (UIImage*) img
                {
    
                for(ZBarSymbol *sym in syms) {
    
                [view stop];
    
                [self closeCameraScanner];
    
        // I am also setting reader to NIL but I don't really know if this is necessary or not.
    
                reader=nil;
            }
    
    
        }
    
    
        -(void)closeCameraScanner{
    
            UIView * v = [self.view viewWithTag:99999999];
            if (nil != v) {
                [v removeFromSuperview];
            }
    
            [self.view endEditing:YES];
    
        }
    

    So, that's a quick and dirty way to do this. I have some additional code for manually creating the overlay and for limiting the scan crop but as far as simply getting it running, this did the trick for me.

提交回复
热议问题