如何在可可中使用IKScannerDeviceView [英] How to use IKScannerDeviceView in Cocoa

查看:123
本文介绍了如何在可可中使用IKScannerDeviceView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用IKScannerDeviceView扫描应用程序内部的文档?

How can I use IKScannerDeviceView to scan a document inside of my app?

我尝试通过IB将IKScannerDeviceView添加到我的视图中,并将其委托设置为我的应用程序委托(实现IKScannerDeviceViewDelegate),但是当我运行该应用程序时,使用按钮 Show Details 获得了一个视图和 Scan ,并且仅启用了 Show Details ,当我单击它时,什么也没有发生.

I tried adding an IKScannerDeviceView into my view through IB and setting its delegate to my app delegate (which implements the IKScannerDeviceViewDelegate), but when I run the app I get a view with the buttons Show Details and Scan, and only Show Details is enabled and when I click it nothing happens.

我插入了扫描仪,可以通过Image Capture进行扫描,但不能通过我的应用程序进行扫描.

I have a scanner plugged in and I can scan through Image Capture, but not through my app.

有人有关于如何使用它的好教程吗?

Does anybody have a good tutorial on how to use it?

推荐答案

我终于能够弄清楚如何使用IKScannerDeviceView.

I was finally able to figure out how to use IKScannerDeviceView.

您的课程必须实现以下委托:

Your class must implement the following delegates:

IKScannerDeviceViewDelegate, ICScannerDeviceDelegate, ICDeviceBrowserDelegate

,您需要在窗口中拥有一个IKScannerDeviceView,并将其委托设置为实现 IKScannerDeviceViewDelegate

and you need to have an IKScannerDeviceView in your window, with its delegate set to the class implementing IKScannerDeviceViewDelegate

要开始使用它,您必须像这样创建一个 ICDeviceBrowser :

To start using it, you must create an ICDeviceBrowser like so:

    ICDeviceBrowser *mDeviceBrowser = [[ICDeviceBrowser alloc] init];
    mDeviceBrowser.delegate = self;
    mDeviceBrowser.browsedDeviceTypeMask = ICDeviceLocationTypeMaskLocal|ICDeviceLocationTypeMaskRemote|ICDeviceTypeMaskScanner;
    [mDeviceBrowser start];

然后以类似于以下方式的方式实现委托方法:

Then implement the delegate methods in a manner similar to this:

- (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
{
    [scanner requestOpenSession];
}
- (void)deviceBrowser:(ICDeviceBrowser*)browser didAddDevice:(ICDevice*)addedDevice moreComing:(BOOL)moreComing
{
    if ( (addedDevice.type & ICDeviceTypeMaskScanner) == ICDeviceTypeScanner )
    {
        [scannerView setScannerDevice:(ICScannerDevice*)addedDevice];
    }
}
-(void)didRemoveDevice:(ICDevice*)removedDevice
{
    [removedDevice requestCloseSession];
}

然后,如果一切顺利,则IKScannerDeviceView将能够与扫描仪进行交互!

Then if all goes right, your IKScannerDeviceView will be able to interact with your scanner!

这篇关于如何在可可中使用IKScannerDeviceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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