IOS7中ZBar SDK速度减慢
我正在尝试使用ZBar实现一些二维码阅读器。 过了一段时间,我确实开始阅读了,但几次阅读后,应用程序的速度越来越慢(直到几乎没有响应)。 此SDK是否与iOS7兼容? 框架:libiconv.dylib、libinfo.dylib、QuartzCore、CoreVideo、CoreMedia、AVFoundation、CoreGraphics、UIKit、XCTestIOS7中ZBar SDK速度减慢,ios,ios7,zbar-sdk,zbar,Ios,Ios7,Zbar Sdk,Zbar,我正在尝试使用ZBar实现一些二维码阅读器。 过了一段时间,我确实开始阅读了,但几次阅读后,应用程序的速度越来越慢(直到几乎没有响应)。 此SDK是否与iOS7兼容? 框架:libiconv.dylib、libinfo.dylib、QuartzCore、CoreVideo、CoreMedia、AVFoundation、CoreGraphics、UIKit、XCTest - (IBAction)scan:(id)sender { //initialize the reader and pr
- (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消耗->。基督:好吧,在检查了这个问题之后,我确实设法解决了这个问题。 我添加的行如下所示: (在my viewcontroller.h中) (在my viewcontroller.m中)
如果您只需要在iOS7上部署,我建议您使用AVFoundation的新API来检测条形码、qrcode和类似内容。为什么不在iOS7中使用AVCaptureSession(natif)来扫描条形码。看看这个教程:这个应用程序必须在iOS6上运行良好:(在iOS6中,我没有减速的问题……奇怪!
@property (strong,nonatomic) ZBarReaderViewController *reader;
if(self.reader)
{
[self.reader.readerView stop];
for(UIView *subViews in self.reader.view.subviews)
[subViews removeFromSuperview];
[self.reader.view removeFromSuperview];
self.reader.view = nil;
}
_reader = [ZBarReaderViewController new];