如何使用 NativeScript 访问 UIPrintInteractionController class

How to access the UIPrintInteractionController class with NativeScript

我正在尝试实现 AirPrint 打印并需要实例化 UIPrintInteractionController。但是,我似乎无法找到 class。我如何从 NativeScript 访问这个 UIKit class?

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

针对您的情况使用以下语法:

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

找到更多详细信息