条形码图像编码适用于模拟器,但不适用于设备

时间:2014-06-03 13:39:07

标签: ios objective-c zxing cgimageref

我使用ZXing框架从字符串中制作条形码图像。当我在模拟器上尝试它时,它工作,但当我在设备上尝试它时,我得到一个错误的访问错误

ZXMultiFormatWriter *writer = [ZXMultiFormatWriter writer];
    ZXBitMatrix* result = [writer encode:self.discountProgramInfo.customerID
                                  format:self.barcodeFormat
                                   width:self.barcodeImageView.frame.size.width
                                  height:self.barcodeImageView.frame.size.height
                                   error:&error];
    if (result) {

        CGImageRef image = [[ZXImage imageWithMatrix:result] cgimage];
        self.barcodeImageView.image = [UIImage imageWithCGImage:image];
        // This CGImageRef image can be placed in a UIImage, NSImage, or written to a file.
    } else {
        NSString *errorMessage = [error localizedDescription];
        DLog("%@",errorMessage);
    }

此行失败:self.barcodeImageView.image = [UIImage imageWithCGImage:image];并且CGImageRef未正确生成。

任何可能导致不匹配的想法?

0 个答案:

没有答案