- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 View 中放置了 UIActivityIndicator
,我试图在扫描条形码后显示它(因为出于某种原因,它不会立即转到我的信息页面上面有加载屏幕。)我尝试在 CaptureOutput
中显示 Indicator,但 [loadView setHidden:NO]
被忽略了。为什么会这样?有没有办法在扫描后立即进行 segue?
BRISBNScanner.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface BRISBNScanner : UIViewController <AVCaptureMetadataOutputObjectsDelegate>
{
IBOutlet UIActivityIndicatorView *loadView;
}
@property (strong, nonatomic) AVCaptureDevice* device;
@property (strong, nonatomic) AVCaptureDeviceInput* input;
@property (strong, nonatomic) AVCaptureMetadataOutput* output;
@property (strong, nonatomic) AVCaptureSession* session;
@property (strong, nonatomic) AVCaptureVideoPreviewLayer* preview;
@property (strong, nonatomic) NSString *isbnText;
@end
BRISBNScanner.m
#import "BRISBNScanner.h"
#import "BRScanInfoView.h"
@interface BRISBNScanner ()
@end
@implementation BRISBNScanner
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Device
self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
// Input
self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];
// Output
self.output = [[AVCaptureMetadataOutput alloc] init];
[self.output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
// Session
self.session = [[AVCaptureSession alloc] init];
[self.session addInput:self.input];
[self.session addOutput:self.output];
self.output.metadataObjectTypes = @[AVMetadataObjectTypeEAN13Code];
// Preview
self.preview = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
self.preview.videoGravity = AVLayerVideoGravityResizeAspectFill;
self.preview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view.layer insertSublayer:self.preview atIndex:0];
// Start
[self.session startRunning];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
{
[loadView setHidden:NO];
[self.session stopRunning];
for(AVMetadataObject *metadataObject in metadataObjects)
{
AVMetadataMachineReadableCodeObject *readableObject = (AVMetadataMachineReadableCodeObject *)metadataObject;
if ([metadataObject.type isEqualToString:AVMetadataObjectTypeEAN13Code])
{
NSLog(@"EAN 13 = %@", readableObject.stringValue);
_isbnText = readableObject.stringValue;
[loadView setHidden:YES];
[self performSegueWithIdentifier:@"showInfo" sender:self];
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
[viewControllers removeObjectIdenticalTo:self];
[self.navigationController setViewControllers: viewControllers animated: YES];
}
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showInfo"]) {
BRScanInfoView *scanView = (BRScanInfoView *)[segue destinationViewController];
//The view that uses the ISBN to search for stuff
scanView.isbnTextprop = _isbnText;
}
}
@end
最佳答案
除非 session 的 metadataObjectsCallbackQueue 设置为主队列(或设置为在其上执行的队列),否则您不会从主线程调用 [loadView setHidden:NO]。 (这可能也是为什么 [self performSegueWithIdentifier:@"showInfo"sender:self] 不会立即转到您的信息页面)。由于大多数 UIKit 不是线程安全的,这会导致“未定义”行为,在这种情况下,不会更改任何内容或仅在分别延迟后才更改。
我的建议是将所有 ui-updates 包装在一个
dispatch_async(dispatch_get_main_queue(), ^{
//ui-updates
});
关于ios - 使用 AVCaptureDevice 读取条形码,我想在扫描后立即显示动画 ActivityIndicator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20107215/
我有一个正在动态生成的条形码,并希望传递给 gsp,该 gsp 稍后将变成 pdf。我不需要出于自己的任何目的保留条形码,只想将图像从 Controller 传递到 gsp。 有没有办法渲染作为变量传
我正在研究苹果“passkit”框架。我已经制作了 lolipop 优惠券,正如它在 guide 中所说的那样. - 创建证书(Apple Dev 网站)我已经编译了.pkpass。 现在我必须使用动
我有这样的代码 $('.testbarcode').barcode('1234567', "code128"); 当我设置样式时它是折线,那么我如何才能将此条码的宽度设置得
我正在将 Visual Basic 应用程序转换为 Python Django。目前,它具有条形码功能来处理商店的销售。这可以用 python django 实现吗? 最佳答案 如果您对条形码功能的定
我正在尝试按照此示例使用条形码 API https://github.com/googlesamples/android-vision/tree/master/visionSamples/barcod
这是我到目前为止所得到的: def encodeFive(zip): zero = "||:::" one = ":::||" two = "::|:|" t
我正在尝试创建具有本文所示格式的条形码:http://www.thebookdesigner.com/2009/10/self-publishing-basics-deciphering-the-bo
我需要一些关于如何从 bmp 文件中获取 12 位条形码的指导,我完全不知道如何处理这个问题。我首先将图像读入 bitmam,我该如何继续? 例子:下图的条码是081034489030。我如何获得这些
谁能告诉我从哪里开始编码以便从 C# 中的 OPOS(Datalogic Magellan 设备)加权和条形码扫描中获取数据?例如,在这种情况下我应该使用什么库和什么函数。我一无所知,因为我已经花了很
使用 zxing,我设法将 Code39 条形码保存为 PNG,但它只显示条形,没有数字。我怎样才能在一个 PNG 中包含条形码和编号? KI 最佳答案 您无法使用 zxing 添加号码。您可以做一些
我正在尝试将扫描的条形码用作 SQL 查询中的变量。我正在使用 Google ML Kit Quick Start项目。我有一个使用 jtds1.3.1 制作的连接和查询功能。我只是无法获得要在查询中
我尝试让程序从下面的代码中读取 EAN13,但它不起作用 func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metada
我必须读取 PDF 文件中的数据矩阵代码,我正在研究其可能性,对此我有一些疑问: 1.- 我与 Itext 合作,我正在寻找有关使用此库读取此 QR 条形码的可能性的信息,但我没有相关结果,这可能吗?
文档和头文件不包含任何与支持 3D 条形码相关的信息。但是,明确提到 AVMetadataMachineReadableCodeObject 支持一维和二维条码。因此,有人知道 AVFoundatio
我一直在寻找解决方案,到目前为止,我认为对我的项目来说最好的解决方案是使用免费的 Code 39 字体。但是,我已经尝试打印一些样本,但我的条形码扫描仪无法读取它们。 我进行了更多研究,偶然发现了 t
生成 3 of 9 很容易条形码使用 Font() Font f = new Font("Free 3 of 9", 80); this.Font = f; Label l = new Label()
愚蠢的我,我以为只要用条形码字体写一些文本,就会让扫描仪读取它。看来我错了。 所以在阅读了一些关于 code128 条形码的文档之后,我了解到: 条形码以(103、104 或 105 取决于类型)开头
我想在 WPF 应用程序中区分(条形码)扫描仪和键盘输入。 我需要的是每当我的扫描仪提供数据时发生的事件。 在我的应用程序中有一个特殊的字段,它将填充来自扫描仪的输入。因此,如果用户关注其他领域,我不
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
是否可以将 ZPL 和二进制数据用于 aztec 条形码? 我尝试使用BluetoothConnection写入发送以UTF8和字节数据编码的字符串连接数组/ String zplStart; byt
我是一名优秀的程序员,十分优秀!