How to get reference to self.view and self.view.frame in NativeScript

為{幸葍}努か 提交于 2019-12-25 06:59:38

问题


I am trying to call the UIPrinterPickerController in NativeScript on an iPad. I've tracked down the call that I need to make and it is here:

UIPrinterPickerController.presentFromRectInViewAnimatedCompletionHandler(rect: CGRect, view: UIView, animated: boolean, completion: (arg1: UIPrinterPickerController, arg2: boolean, arg3: NSError) => void): boolean;

In the examples I've seen the rect param is a reference to self.view.frame and the view param is a reference to self.view. How do I find those references in NativeScript? I've tried the ui.view module and that doesn't work. I've tried args.object from the pageLoaded event and that doesn't work. Any help would be appreciated.

// My code here
if ( ! UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    found = printPicker.presentAnimatedCompletionHandler(false, completionHandler);
} else {
    found = printPicker.presentFromRectInViewAnimatedCompletionHandler(view.frame, view, false, completionHandler);
}

回答1:


You were actually very close; the UIView for the Page; would be:

var pageLoaded = function(args) {
  var page = args.object;  // Get the NativeScript Page object
  var uiView = page.ios;   // Get the underlying iOS native Control
}


来源:https://stackoverflow.com/questions/36812469/how-to-get-reference-to-self-view-and-self-view-frame-in-nativescript

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