Question

When i open directly my camera's view to the QRCode, it crashes. But when i do not open my camera's view directly at start to the QRCode, it works fine. i already tried the same code with an empty app and it works perfectly. it just occurs that situation. All IBOutlets and IBActions are working, Here is my code:

SerialController.h:

#import <UIKit/UIKit.h>
#import "ZBarSDK.h"

@interface SerialController : UIViewController <ZBarReaderDelegate>

@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
@property (weak, nonatomic) IBOutlet UILabel *description;
@property (weak, nonatomic) IBOutlet UIImageView *key;
@property (weak, nonatomic) IBOutlet UILabel *resultText;


@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *qrSearchButton;

@property (weak, nonatomic) IBOutlet UIView *contentHolder;

@property (weak, nonatomic) IBOutlet UIImageView *turkcellLogo;
@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage;
@end

SerialController.m

- (IBAction)handleQrSearchButtonTap:(id)sender {


    ZBarReaderViewController *codeReader = [ZBarReaderViewController new];
    codeReader.readerDelegate=self;
    codeReader.supportedOrientationsMask = ZBarOrientationMaskAll;

    ZBarImageScanner *scanner = codeReader.scanner;
    [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];

    [self presentViewController:codeReader animated:YES completion:nil];

}

#pragma mark - ZBar's Delegate method

- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    //  get the decode results
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];

    ZBarSymbol *symbol = nil;
    for(symbol in results)
        // just grab the first barcode
        break;

    // showing the result on textview
    self.resultText.text = symbol.data;



    // dismiss the controller
    [reader dismissViewControllerAnimated:YES completion:nil];
}
Was it helpful?

Solution

You don't want to use property called description. I just spent couple hours trying to fix exactly same problem. description is standard method in NSObject and you're hiding it. Rename it to something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top