iPhone iOS:您可以在 ZBar 条码扫描中添加十字准线或其他视觉指示器吗?

发布于 2024-11-13 10:28:51 字数 87 浏览 8 评论 0原文

我想知道在 iPhone/iOS 应用程序中使用 Zbar 条形码扫描时是否可以在屏幕上添加某种类型或十字准线或其他视觉指示器,以帮助用户将相机瞄准 QR 码?

I want to know if it is possible when using Zbar barcode scanning within an iPhone/iOS app to add some sort or crosshairs or other visual indicator to the screen to assist users in aiming their camera onto a QR code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北凤男飞 2024-11-20 10:28:51

最好使用透明的 PNG 来实现这一点。只需将其导入到您的项目中,然后创建一个新的 UIImageView 并将其提供给读者。

我这样做是为了添加一个徽标:

// Create the reader
self.reader = [ZBarReaderViewController new];
self.reader.readerDelegate = self;

// Create image for adding a logo :)
UIImage *image = [UIImage imageNamed:@"scan_logo.png"];
UIImageView *imageLogo = [[UIImageView alloc] initWithImage:image];
imageLogo.frame = CGRectMake(0, 0, image.size.width, image.size.height);

// Configure reader
self.reader.cameraOverlayView = imageLogo;

要使图像位于中心,只需将框架定位从:

imageLogo.frame = CGRectMake(0, 0, image.size.width, image.size.height);

更改为:

imageLogo.center = CGRectMake(320/2, 460/2, image.size.width, image.size.height);

That is best accomplished with a transparent PNG. Just import it to your project and then create a new UIImageView that you give to the reader.

I did this to add a logo:

// Create the reader
self.reader = [ZBarReaderViewController new];
self.reader.readerDelegate = self;

// Create image for adding a logo :)
UIImage *image = [UIImage imageNamed:@"scan_logo.png"];
UIImageView *imageLogo = [[UIImageView alloc] initWithImage:image];
imageLogo.frame = CGRectMake(0, 0, image.size.width, image.size.height);

// Configure reader
self.reader.cameraOverlayView = imageLogo;

To get the image in the center just change the frame positioning from:

imageLogo.frame = CGRectMake(0, 0, image.size.width, image.size.height);

To something like:

imageLogo.center = CGRectMake(320/2, 460/2, image.size.width, image.size.height);
晨光如昨 2024-11-20 10:28:51

FWIW 我在我的应用程序中所做的是扩展 ZBarReaderViewController 类,将我的新类也设置为 ZBarReaderDelegate,然后将 JeroenEijkhof 的代码放入我的 init 覆盖中:

- (id) init
{
    self = [super init];
    if( self ) {
        self.readerDelegate = self;
        UIImage *image = [UIImage imageNamed:...
        ...
    }
    return self;
}

这使我能够控制视图的其他方面,例如自定义viewDidLoadviewWillAppear 上的导航控制器,因为我在 NavigationController 视图堆栈中实现相机视图,并且希望能够添加标题栏、工具栏等,而不是以模态方式呈现它,如 zbar 文档所示。

FWIW what I did in my app is to extend the ZBarReaderViewController class, set my new class as the ZBarReaderDelegate also, and then put JeroenEijkhof's code into my init override:

- (id) init
{
    self = [super init];
    if( self ) {
        self.readerDelegate = self;
        UIImage *image = [UIImage imageNamed:...
        ...
    }
    return self;
}

This gave me the ability to control other aspects of the view, such as customizing the navigation controller on viewDidLoad and viewWillAppear since I was implementing the camera view in a NavigationController view stack and wanted the ability to add the titlebar, toolbar, etc. instead of presenting it modally, as the zbar docs demonstrate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文