我有一个从故事板创建的具有216x20像素的ZBarReaderView,显示为大约230x50像素,因为ZBarReaderView不会使它的尺寸太严重... 这一切都运行得很好,但是当我在那个readerView上调用start时它表现得很奇怪。它启动凸轮,但是在半秒之后,readerView会稍微缩放,而readerView内的摄像头图像会向下移动,然后再向上移动。 这并不可怕,但看起来有点糟糕。任何人都有任何想法可能导致这个以及如何解决它?也许sdk对于扫描仪的准备情况有一些隐藏的回调,我可以隐藏它直到扫描仪说它准备就绪然后显示扫描仪就像.5秒后......
barcodeReader是ZBarReaderView的iboutlet,scanLoading是uiactivityindicatorview的iboutlet,它会在加载扫描仪之前进行动画处理。 这些是默认情况下更改的唯一设置,当然除了在故事板中设置的框架外。
[barcodeReader setReaderDelegate:self];
[barcodeReader setAllowsPinchZoom:false];
[barcodeReader start];
/* this works because [barcodeReader start] blocks ui updates until the scanner
is running, i know it's not a good solution but since there doesn't seem to
be a callback or delegate method like scannerDidStart or something it seems
to be the only way... */
[scannerLoading stopAnimating];
感谢您的帮助!
答案 0 :(得分:3)
我刚刚发布了一个报复问题的答案:
ZBarReadview with custom size from StoryBoard,but when it's called,it's size is not I set
也许答案也解决了你的问题。
简而言之:
使用Interface Builder或Storyboard创建视图并为其分配ZBarReaderView时,您必须在相机图像的属性中选中“剪辑子视图”以保持视图的大小。
答案 1 :(得分:0)
只需添加另一个视图,使其成为具有图像视图的cameraoverlayview,图像视图中所需的部分为透明。然后在按钮操作中
// ADD:提供从相机提要中扫描的条形码阅读器
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
reader.sourceType=UIImagePickerControllerSourceTypeCamera;
//reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
reader.cameraOverlayView=cameraOverlay;
if( [UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront ])
{
reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
ZBarImageScanner *scanner = reader.scanner;
reader.wantsFullScreenLayout = YES;
// 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];
reader.showsZBarControls = NO;
// present and release the controller
[self presentModalViewController:reader animated:YES]; // [appdel.navigationController pushViewController:reader animated:YES];
//[reader.view addSubview:collect];
[reader release];add this and then also add
` - (void)imagePickerController:(UIImagePickerController *)阅读器 didFinishPickingMediaWithInfo:(NSDictionary *)info { // ADD:获取解码结果 id results = [info objectForKey:ZBarReaderControllerResults]; ZBarSymbol * symbol = nil; for(结果中的符号) //示例:抓住第一个条形码 打破;
[self rewards:symbol.data];
} `
作为一种方法.hope这将解决您的问题