在ZBar扫描仪上方添加覆盖 [英] Add overlay over top of ZBar scanner

查看:109
本文介绍了在ZBar扫描仪上方添加覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ZBar SDK 在iPhone上读取QR码,但是,我想在相机/扫描仪视图的底部添加一些文本,以供用户参考.这是我到目前为止的内容:

I'm using the ZBar SDK to read QR codes on iPhone, however I want to add some text to the bottom of the camera/scanner view that is instructional text for the user. Here is what I have so far:

UIView *cameraOverlayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    cameraOverlayView.backgroundColor = [UIColor redColor];

    UILabel *instructionLabel = [[UILabel alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [instructionLabel setTextColor:[UIColor grayColor]];
    [instructionLabel setBackgroundColor:[UIColor clearColor]];
    [instructionLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 24.0f]];
    [instructionLabel setCenter:cameraOverlayView.center];
    [cameraOverlayView addSubview:instructionLabel];

    reader.cameraOverlayView = cameraOverlayView;
    reader.wantsFullScreenLayout = YES;

    [instructionLabel release];
    [cameraOverlayView release];

这是完整的课程:

https://gist.github.com/4163761

不幸的是,标签没有显示. ZBar的文档说要为此目的使用cameraOverlayView,但是似乎不起作用.

Unfortunately, the label doesn't show. ZBar's documentation says to use the cameraOverlayView for this purpose, however it doesn't seem to be working.

另一个要注意的是,我正在使用Titanium框架,所以那是多余的Titanium类的来源,但是我的问题应该特定于ZBar.

One other note, I'm using the Titanium framework, so that's where the extra Titanium classes are from, however my question should be specific to ZBar.

推荐答案

您完全看不到cameraOverlayView吗?将背景颜色设置为红色或其他颜色:cameraOverlayView.backgroundColor = [UIColor redColor];

Do you see the cameraOverlayView at all? set the background color to red or something: cameraOverlayView.backgroundColor = [UIColor redColor];

如果根本看不到cameraOverlayView,则可能需要设置阅读器. showsZBarControls = NO,它将禁用默认控件并使用您的自定义叠加层.

If you don't see the cameraOverlayView at all, then probably you need to set reader. showsZBarControls = NO which will disable the the default controls and use your custom overlay.

如果确实看到cameraOverlayView,则标签可能在边界之外.试探原点并将其放置到位.

If you do see the cameraOverlayView, then the label is probably outside the bounds. Play around with the origin points and get it into position.

顺便说一句,我看到您没有使用ARC,请确保您发布了structionLabel!

BTW I see you're not using ARC, make sure you release instructionLabel!

这篇关于在ZBar扫描仪上方添加覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆