我正在尝试使用 ZBar 实现一些二维码阅读器。过了一会儿,我确实设法阅读了,但是在阅读了几次之后,应用程序变得越来越慢(直到几乎没有响应)。这个 SDK 兼容 iOS7 吗?框架:libiconv.dylib、libinfo.dylib、QuartzCore、CoreVideo、CoreMedia、AVFoundation、CoreGraphics、UIKit、XCTest
- (IBAction)scan:(id)sender {
//initialize the reader and provide some config instructions
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
[reader.scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 1];
reader.cameraFlashMode=UIImagePickerControllerCameraFlashModeOff;
reader.readerView.zoom = 1.0; // define camera zoom property
//show the scanning/camera mode
[self presentModalViewController:reader animated:YES];
// Do any additional setup after loading the view from its nib.
}
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info {
//this contains your result from the scan
id results = [info objectForKey: ZBarReaderControllerResults];
//create a symbol object to attach the response data to
ZBarSymbol *symbol = nil;
//add the symbol properties from the result
//so you can access it
for(symbol in results){
//symbol.data holds the value
NSString *upcString = symbol.data;
//print to the console
NSLog(@"the value of the scanned UPC is: %@",upcString);
NSMutableString *message = [[NSMutableString alloc]
initWithString: @"Scanned Barcode: "];
[message appendString:[NSString stringWithFormat:@"%@ ",
upcString]];
//Create UIAlertView alert
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Product Barcode" message: message delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
self.viewResult.text = upcString;
[alert show];
//After some time
[alert dismissWithClickedButtonIndex:0 animated:TRUE];
//make the reader view go away
[reader dismissModalViewControllerAnimated: YES];
}
}
编辑:4 或 5 次读数后,这是内存和 CPU 消耗 -> http://diogomend.me/images/capt.png。基督 :D