【问题标题】:Connecting ZXing to a button in xcode将 ZXing 连接到 xcode 中的按钮
【发布时间】:2012-12-06 08:22:44
【问题描述】:

我是编程新手,所以我敢肯定这个问题非常基础(请耐心等待!)

我刚刚将 zxing 安装到我当前的 xcode 4.5 项目中。我花了一段时间来解决这些错误,但我终于明白了。

我创建了一个名为“scan”的按钮,我希望在其中调用 zxing。我怎样才能做到这一点?

我尝试查看在源文件中实现的文件,但无法确定要使用哪些类和方法。

是的,我尝试用谷歌搜索这个非常基本的概念,但什么也没找到:(

【问题讨论】:

  • 我不能代表ZXing,我没用过。但是,如果你不明白,我在 ZBarSDK 上很幸运 - zbar.sourceforge.net/iphone/sdkdoc
  • 我不认为 Zxing 与它有任何关系。你应该学习的是如何创建控件以及如何处理它们上的用户交互。

标签: iphone ios xcode button zxing


【解决方案1】:

这是您需要在扫描按钮操作中添加的代码。

- (IBAction)scanPressed:(id)sender
 {

            ZXingWidgetController *widController = [[ZXingWidgetController alloc]  initWithDelegate:self showCancel:YES OneDMode:NO];

            NSMutableSet *readers = [[NSMutableSet alloc ] init];

            <#if ZXQR>

                QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
                [readers addObject:qrcodeReader];

           <#endif>

           <#if ZXAZ>
                AztecReader *aztecReader = [[AztecReader alloc] init];
                [readers addObject:aztecReader];

           <#endif>

                widController.readers = readers;

                [self presentModalViewController:widController animated:YES];

}

在您的应用中使用此代码之前,请删除“”符号。

【讨论】:

  • 非常感谢 Abhishek,正是我正在寻找的直接答案!
猜你喜欢
  • 2012-05-05
  • 2017-08-20
  • 1970-01-01
  • 2021-12-16
  • 2013-02-19
  • 1970-01-01
  • 2011-09-27
  • 1970-01-01
  • 2016-01-09
相关资源
最近更新 更多