How to access the UIPrintInteractionController class with NativeScript

僤鯓⒐⒋嵵緔 提交于 2019-12-13 07:37:20

问题


I'm trying to implement AirPrint printing and need to instantiate UIPrintInteractionController. However, I can't seem to get it to find the class. How can I access this UIKit class from NativeScript?

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

回答1:


Use the following syntax for your case :

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

Here are some more example for Objective-C to JS based on the {N} documenation

Objective-C code

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 code

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

More details can be found at NativeScript documentation



来源:https://stackoverflow.com/questions/36780044/how-to-access-the-uiprintinteractioncontroller-class-with-nativescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!