我将以下功能与Zbar文件一起使用,以拍摄条形码的照片
- (IBAction)scanUPCBtnActn:(id)sender {
//check camera available or not
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIDeviceOrientationLandscapeLeft == orientation)
{
//Rotate 90
reader.cameraViewTransform = CGAffineTransformMakeRotation (4*M_PI/2.0);
} else if (UIDeviceOrientationLandscapeRight == orientation) {
//Rotate 270
reader.cameraViewTransform = CGAffineTransformMakeRotation (4*M_PI/2.0);
}
// present and release the controller
[self.navigationController presentViewController:reader animated:YES completion:nil];
}
else
{
UIAlertView *cameraAlert=[[UIAlertView alloc]initWithTitle:@"Camera Alert" message:@"Camera Not Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[cameraAlert show];
}
}
我在我的项目中有zbar的文件,但是当我单击“提交”按钮时,它会打开相机,但是它不显示图标相机来拍照,而且我不知道我是否有手动添加此按钮或将其添加到zbar文件中,因为我没有可添加此按钮的屏幕或界面。 任何帮助将不胜感激! 谢谢