本机脚本addSubview [英] Nativescript addSubview

查看:85
本文介绍了本机脚本addSubview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将OpenTok SDK实施到Nativescript中,但遇到了一个似乎无法解决的问题.

I'm trying to implement the OpenTok SDK into Nativescript and I've run into an issue that I can't seem to wrap my head around.

根据他们的文档( https://tokbox.com/developer/指南/publish-stream/ios/#create_publisher )创建调用的发布者对象后:

Per their documentation (https://tokbox.com/developer/guides/publish-stream/ios/#create_publisher) once you create a publisher object you call:

[self.view addSubview:publisher.view];

即使有可能,我也不知道如何将其绑定到Nativescript中.

I can't figure out how I would tie this into Nativescript, if it's even possible.

我的第一个想法是,我想在XML页面上使用UIView或View元素,然后在该元素上调用.addView(publisher.view);.

My first thought is that I would want a UIView or View element on my page in the XML, then I would call .addView(publisher.view); on that element.

这里有一个类似的问题(注入纯Java/NativeScript App中的Obj-C代码),但没有任何结果,一个答案并没有提供太多帮助.

There is a similar question here (Inject pure Java / Obj-C code in NativeScript App) but nothing came of it, the one answer does't provide much help.

我克隆了OpenTok的一个示例项目,并在以下要点中添加了对此调用的实现: https: //gist.github.com/bondydaa/2db355ed45b7e50e4071

I cloned one of OpenTok's sample projects and added their implementation of this call into a gist here: https://gist.github.com/bondydaa/2db355ed45b7e50e4071

您可以在第117 行中看到它们的实现方式这个电话.这段代码对我提出了另一个问题,因为我不确定_publisherView的来源.

You can see at line 117 how they implemented this call. This code raises another question for me in that I'm not sure where _publisherView comes from.

任何帮助将不胜感激!

推荐答案

在Nativescript中,您可以尝试调用要向其添加组件的容器的'ios'属性.这将返回本机对象.

In Nativescript you can try calling the 'ios' property of the container you are trying to add the component to. This will return the native object.

例如,如果您具有StackLayout,则可以:

For example if you have a StackLayout, you can:

var stackLayout = args.object.getViewById("theIdOfTheStackLayout");
stackLayout.ios.addSubview(publisher.view);

这篇关于本机脚本addSubview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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