如何使用NativeScript访问UIPrintInteractionController类

时间:2016-04-21 20:41:27

标签: javascript nativescript airprint

我尝试实施AirPrint打印并需要实例化UIPrintInteractionController。但是,我似乎无法找到它。如何从NativeScript访问此UIKit类?

function findPrinter() {
    var printController = UIPrintInteractionController.new();
    console.log(printController);
}
exports.findPrinter = findPrinter;

1 个答案:

答案 0 :(得分:2)

根据您的情况使用以下语法:

function findPrinter() {
    var printController = UIPrintInteractionController;
    console.log(printController.isPrintingAvailable());
}
exports.findPrinter = findPrinter;

以下是基于{N}文档

的Objective-C到JS的更多示例

Objective-C 代码

NSMutableArray * array = [[NSMutableArray alloc] init];
Class buttonClass = [UIButton class];
UIButton * button = [[buttonClass alloc] init];
[array setObject: buttonClass atIndex: 0];
[array setObject: button atIndex: 1];

NativeScript 代码

var array = new NSMutableArray();
var buttonClass = UIButton;
var button = new buttonClass();
array.setObjectAtIndex(buttonClass, 0);
array.setObjectAdIndex(button, 1);

可在NativeScript documentation

找到更多详情