我使用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
未正确生成。
任何可能导致不匹配的想法?